【ROS报错】“c++: error: $[catkin

【ROS报错】“c++: error: $[catkin,第1张

项目场景

ROS编译的过程中,出现报错:“c++: error: $[catkin_LIBRARIES]: 没有那个文件或目录”错误


问题描述

编译的过程中,详细报错如下:

[ 50%] Building CXX object test_pkg/CMakeFiles/hello.dir/src/helloworld.cpp.o
[100%] Linking CXX executable /home/zzw/test_ws/devel/lib/test_pkg/hello
c++: error: $[catkin_LIBRARIES]: 没有那个文件或目录
make[2]: *** [test_pkg/CMakeFiles/hello.dir/build.make:84/home/zzw/test_ws/devel/lib/test_pkg/hello] 错误 1
make[1]: *** [CMakeFiles/Makefile2:688:test_pkg/CMakeFiles/hello.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
Invoking "make -j8 -l8" failed
mInStream.read(buffer);
		mHandler.obtainMessage(READ_DATA, bytes, -1, buffer).sendToTarget();
	}

原因分析:

Cmakelist.txt编译文件写错了。之前错误写成:

add_executable(节点名 src/文件名)
target_link_libraries(节点名  $[catkin_LIBRARIES])
解决方案:

cmakelist中给出的规则提示:

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/test_pkg_node.cpp)

## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
#   ${catkin_LIBRARIES}
# )

修改为:

add_executable(节点名 src/文件名)
target_link_libraries(节点名  ${catkin_LIBRARIES})

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/872784.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-13
下一篇2022-05-13

发表评论

登录后才能评论

评论列表(0条)

    保存