对 org::opensplice::core::DWDeleter::DWDeleter 的未定义引用

Posted

技术标签:

【中文标题】对 org::opensplice::core::DWDeleter::DWDeleter 的未定义引用【英文标题】:undefined reference to org::opensplice::core::DWDeleter::DWDeleter 【发布时间】:2015-03-30 13:07:26 【问题描述】:

我是 OpenSplice 的新手,想从这里编译简单的教程:

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

我下载了 OpenSplice 社区版并获取了 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&) 的引用未定义

libdcpsisocpp.so 被添加到定义此引用的链接目标(参见@​​987654322@)。

我已经通过更改为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 中存在同样的问题,日期 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/

【问题讨论】:

检查是否需要使用 lib 编译命令进行某种开关 【参考方案1】:

问题是包含的库不是用 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 感谢您指出这一点!!

【讨论】:

以上是关于对 org::opensplice::core::DWDeleter::DWDeleter 的未定义引用的主要内容,如果未能解决你的问题,请参考以下文章

初一数学教案有序数对

如何对List 进行排序

根据对的第二个值查找对向量的上限

算法之逆序对

10:素数对

向量对还是向量对?