1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 <2022> 2023 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 <2022> 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: linking problem with str::tr1::shared_ptr |
From: | Francisco Ramos via Tech-talk <tech-talk at aps.anl.gov> |
To: | Michael Davidsaver <mdavidsaver at gmail.com> |
Cc: | EPICS tech-talk <tech-talk at aps.anl.gov> |
Date: | Mon, 4 Apr 2022 20:46:44 -0400 |
> Thank you in advance and also for the good responses that have allowed us to move forward.
The short answer is that you should build all of the C++ parts of Base
with the same compiler version and arguments. Including "-std=*".
https://github.com/epics-base/pvDataCPP/blob/f3911d583139ac5969df6a992c424788e41d9634/src/misc/pv/sharedPtr.h#L62-L86
On 4/4/22 13:20, Francisco Ramos via Tech-talk wrote:
> Hello Community,
>
> I am writing to see if you could help us with the following problem we have. After making a merge between an old version and a new one (our c++ code) that now uses EPICS 7 (7.0.6.2-DEV), we get a compilation error in the linking process, that is, the library compiles correctly but when we try to compile the examples we get the error "libgiapi-glue-cc. so: *undefined reference to `epics::pvDatabase::PVDatabase::addRecord*(std::shared_ptr<epics::pvDatabase::PVRecord> const&)'"".
>
> Analysing the built library (libgiapi-glue-cc.so.0.16) to see the symbols defined, we have used the nm tool. We can see that the addRecord function requires the *std::shared::ptr parameter* (it must be defined in the libpvDatabase.so.4.6.1 library). The output of the nm command is copied below.
> nm --format sysv libgiapi-glue-cc.so.0.16 | c++filt | grep addR
> *epics::pvDatabase::PVDatabase::addRecord(std::shared_ptr<epics::pvDatabase::PVRecord>* const&)| | | U | NOTYPE| | |*UND*
>
> Now, if we analyze the EPICS library *libpvDatabase.so.4.6.1*, we get that the "addRecord" function requires the parameter std::tr1::shared_ptr instead of std::shared_ptr. The output of the nm command is copied below.
> *epics::pvDatabase::PVDatabase::addRecord(std::tr1::shared_ptr<epics::pvDatabase::PVRecord> const&)*| |000000000004c120| T | FUNC|0000000000000370| | |.text
>
> If we analyze the source code, we can see that the PVImageRecordPtr type has been defined with std::tr1::shared_ptr. Below you can se the code extract or in the following link(https://github.com/framos-gemini/giapi-glue-cc/blob/peterMerge/src/data/PVImageAgent.h <https://github.com/framos-gemini/giapi-glue-cc/blob/peterMerge/src/data/PVImageAgent.h>, line 136 and 250)
>
> /class PVImageRecord;
> // typedef std::tr1::shared_ptr<PVImageRecord> PVImageRecordPtr;
> // PVImageRecordPtr pvImageRecord;/
>
>
> Next, the PVImageRecord class inherits from the epics::pvDatabase::PVRecord class, which defines the create method. Below is a small fragment of the code: (https://github.com/framos-gemini/giapi-glue-cc/blob/peterMerge/src/data/PVImageAgent.cpp <https://github.com/framos-gemini/giapi-glue-cc/blob/peterMerge/src/data/PVImageAgent.cpp>).
>
> / class PVImageRecord: public epics::pvDatabase::PVRecord {
> public:
> POINTER_DEFINITIONS(PVImageRecord);
> static PVImageRecordPtr create(std::string const & recordName, LoggerPtr lg)/
>
>
> In the same PVImageAgent.cpp file, line 606, is where the record is introduced. As you can see, the *addRecord function is being called* with the *std::tr1::shared_ptr *type (PVImageRecordPtr pvImageRecord) instead of *std::shared_ptr.* Therefore, it is strange what is happening. Any suggestions?
>
> Thank you in advance and also for the good responses that have allowed us to move forward.
>
> Regards,