c++data-distribution-serviceopensplice

undefined reference to org::opensplice::core::DWDeleter::DWDeleter


I'm new to OpenSplice and wanted to complie the simple tutorial from here:

https://github.com/PrismTech/dds-tutorial-cpp-ex

I downloaded OpenSplice Community Edition and sourced the release.com file.

Then I cloned the dds-tutorial-cpp-ex git repository and tried to build ch1:

$ cd ch1
$ cmake .
$ make
Scanning dependencies of target datamodel
[ 11%] Generating gen/TempControl.cpp, gen/TempControl.h, gen/TempControlDcps.cpp, gen/TempControlDcps.h, gen/TempControlDcps_impl.cpp, gen/TempControlDcps_impl.h, gen/TempControlSplDcps.cpp, gen/TempControlSplDcps.h, gen/ccpp_TempControl.h
[ 22%] Building CXX object CMakeFiles/datamodel.dir/gen/TempControl.cpp.o
[ 33%] Building CXX object CMakeFiles/datamodel.dir/gen/TempControlDcps.cpp.o
[ 44%] Building CXX object CMakeFiles/datamodel.dir/gen/TempControlDcps_impl.cpp.o
[ 55%] Building CXX object CMakeFiles/datamodel.dir/gen/TempControlSplDcps.cpp.o
Linking CXX shared library libdatamodel.so
[ 55%] Built target datamodel
Scanning dependencies of target tspub
[ 66%] Building CXX object CMakeFiles/tspub.dir/tspub.cpp.o
[ 77%] Building CXX object CMakeFiles/tspub.dir/util.cpp.o
Linking CXX executable tspub
CMakeFiles/tspub.dir/tspub.cpp.o: In function `dds::pub::detail::DataWriter<tutorial::TempSensorType>::DataWriter(dds::pub::TPublisher<org::opensplice::pub::PublisherDelegate> const&, dds::topic::Topic<tutorial::TempSensorType, dds::topic::detail::Topic> const&, dds::core::TEntityQos<org::opensplice::pub::qos::DataWriterQosImpl> const&, dds::core::status::StatusMask const&)':
/home/user/workspace/HDE/x86_64.linux/include/dcps/C++/isocpp/dds/pub/detail/DataWriter.hpp:241: undefined reference to `org::opensplice::core::DWDeleter::DWDeleter(std::shared_ptr<DDS::Publisher> const&)'
CMakeFiles/tspub.dir/tspub.cpp.o: In function `dds::topic::detail::Topic<tutorial::TempSensorType>::Topic(dds::domain::TDomainParticipant<org::opensplice::domain::DomainParticipantDelegate> const&, std::string const&, std::string const&, dds::core::TEntityQos<org::opensplice::topic::qos::TopicQosImpl> const&, dds::topic::TopicListener<tutorial::TempSensorType>*, dds::core::status::StatusMask const&)':
/home/user/workspace/HDE/x86_64.linux/include/dcps/C++/isocpp/dds/topic/detail/Topic.hpp:87: undefined reference to `org::opensplice::core::TopicDeleter::TopicDeleter(std::shared_ptr<DDS::DomainParticipant> const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [tspub] Error 1
make[1]: *** [CMakeFiles/tspub.dir/all] Error 2
make: *** [all] Error 2

Unfortunately, there's a undefined reference to `org::opensplice::core::DWDeleter::DWDeleter(std::shared_ptr const&)

The library libdcpsisocpp.so is added to the linking target (see https://github.com/PrismTech/dds-tutorial-cpp-ex/blob/master/cmake/FindOpenSplice.cmake#L56) which defines this reference.

I already rebuilt the library by changing into HDE/x86_64.linux/custom_lib folder and executing make -f Makefile.Build_DCPS_ISO_Cpp_Lib which finished without errors.

Why do I get this error? How can I fix it?

My system is Ubuntu 14.04 amd64.

OpenSplice version is: OpenSplice HDE Release V6.4.140407OSS For x86_64.linux, Date 2014-04-15

EDIT: Same problem exists in OpenSplice OpenSplice HDE Release V6.5.0p1 For x86_64.linux, Date 2015-03-19

There the errors are:

undefined reference to `org::opensplice::core::DRDeleter::DRDeleter(std::shared_ptr<DDS::Subscriber> const&)'
undefined reference to `org::opensplice::core::TopicDeleter::TopicDeleter(std::shared_ptr<DDS::DomainParticipant> const&)'

Note: Crosspost with (without any answer): http://forums.opensplice.org/index.php?/topic/2517-undefined-reference-to-orgopensplicecoredwdeleterdwdeleter/


Solution

  • The problem was that the library which was included wasn't built with C++11 support, thus it used Boost shared pointers instead of the C++11 ones but somehow the tutorial code uses C++11.

    Editing the Makefile HDE/x86_64.linux/custom_lib/Makefile.Build_DCPS_ISO_Cpp_Lib and adding -std=c++0x to the CPPFLAGS line fixed the problem.

    (Don't forget to recompile with make -f Makefile.Build_DCPS_ISO_Cpp_Lib)

    @yasir-majeed Thanks for pointing this out!!