我是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版本是:用于x86_64.linux的OpenSplice HDE发行版V6.4.140407OSS,日期2014-04-15
编辑:
OpenSplice OpenSplice HDE版本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/
最佳答案
问题在于所包含的库不是使用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的引用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29347056/