对符号'_ZN3ros10NodeHandle9subscribeERNS_16SubscribeOptionsE'的未定义引用
undefined reference to symbol '_ZN3ros10NodeHandle9subscribeERNS_16SubscribeOptionsE'
我只是想用ROS编译一个程序。我已经链接了所有必要的库,但这个我找不到。我得到的只是代码块中的以下错误(也在 eclipse 中(。
有人知道如何摆脱这个错误吗?甚至需要哪个库?
/usr/bin/ld:CMakeFiles/DistanceKinectDemo.dir/src/DistanceKinectDemo.cpp.o: undefined reference to symbol
'_ZN3ros10NodeHandle9subscribeERNS_16SubscribeOptionsE'
/opt/ros/kinetic/lib/libroscpp.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
gpuvoxelgetpointcloud/CMakeFiles/DistanceKinectDemo.dir/build.make:370: recipe for target
'/home/pcl_gpu/devel/lib/gpuvoxelgetpointcloud/DistanceKinectDemo' failed
make[2]: *** [/home/shupeng/pcl_gpu/devel/lib/gpuvoxelgetpointcloud/DistanceKinectDemo] Error 1
CMakeFiles/Makefile2:1130: recipe for target 'gpuvoxelgetpointcloud/CMakeFiles/DistanceKinectDemo.dir/all' failed
链接器在库列表中找不到该符号。 调用find_package(catkin REQUIRED COMPONENTS ...
时,必须列出组件roscpp
。此外,您需要在target_link_libraries
呼叫中添加${catkin_LIBRARIES}
。 最后,用于链接的库应按依赖项的降序列出,这意味着如果您有其他库依赖于它,则应将${catkin_LIBRARIES}
放在target_link_libraries
调用的末尾。 最后,您的CMakeLists.txt
文件应如下所示:
...
find_package(catkin REQUIRED COMPONENTS roscpp <more packages>)
...
add_executable(DistanceKinectDemo <your cpp files>)
...
target_link_libraries(DistanceKinectDemo
<all your libraries and other dependencies>
${catkin_LIBRARIES}
)
相关文章:
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 对Py_Initialize()的未定义引用
- 使用mysql c++连接器的未定义引用
- 对 Scalar ::Scalar() 的未定义引用
- 对复制 CTOR 和 CTOR 的未定义引用
- 对显式实例化的模板函数的未定义引用
- TensorRT (C++ API) 对"createNvOnnxParser_INTERNAL"的未定义引用
- 2个模板化类的非模板友元函数未定义引用错误
- 编译 libfluid 样本控制器时对"event_base_del_virtual"的未定义引用
- 获取对function_name的未定义引用
- 对 'std::thread::_M_start_thread CMake 的未定义引用进行基准测试
- 对结构方法的未定义引用
- 使用内联函数 c++ 的未定义引用
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 对 DLOPEN 的未定义引用
- QT C++中对全局变量的未定义引用
- 快速数学导致对"__pow_finite"的未定义引用
- 对 boost::system::d etail::system_category_instance 的未定义引用,从
- OpenCV 3.4.3 中对 'cv::String::d eallocate()' 错误的未定义引用