我是 OpenSplice 的新手,想从这里开始学习简单教程:
https://github.com/PrismTech/dds-tutorial-cpp-ex
我下载了 OpenSplice Community Edition 并获取了 release.com 文件。
然后我克隆了 dds-tutorial-cpp-ex git 存储库并尝试构建 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
不幸的是,存在对`org::opensplice::core::DWDeleter::DWDeleter(std::shared_ptr const&) 的 undefined reference
库 libdcpsisocpp.so
被添加到定义此引用的链接目标(请参阅 https://github.com/PrismTech/dds-tutorial-cpp-ex/blob/master/cmake/FindOpenSplice.cmake#L56)。
我已经通过切换到 HDE/x86_64.linux/custom_lib
文件夹并执行 make -f Makefile.Build_DCPS_ISO_Cpp_Lib
重建了库,没有出现错误。
为什么会出现此错误?我该如何解决?
我的系统是 Ubuntu 14.04 amd64。
OpenSplice 版本为:OpenSplice HDE Release V6.4.140407OSS For x86_64.linux,日期 2014-04-15
编辑: 同样的问题存在于OpenSplice OpenSplice HDE Release V6.5.0p1 For x86_64.linux, Date 2015-03-19
错误是:
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&)'
注意:交叉邮寄(没有任何答案):http://forums.opensplice.org/index.php?/topic/2517-undefined-reference-to-orgopensplicecoredwdeleterdwdeleter/
最佳答案
问题是所包含的库不是使用 C++11 支持构建的,因此它使用了 Boost 共享指针而不是 C++11 共享指针,但教程代码以某种方式使用了 C++11。
编辑 Makefile HDE/x86_64.linux/custom_lib/Makefile.Build_DCPS_ISO_Cpp_Lib
并将 -std=c++0x
添加到 CPPFLAGS 行解决了问题。
(不要忘记使用 make -f Makefile.Build_DCPS_ISO_Cpp_Lib
重新编译)
@yasir-majeed 感谢您指出这一点!!
关于c++ - 对 org::opensplice::core::DWDeleter::DWDeleter 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29347056/