【ROS报错】“c++: error: $[catkin_LIBRARIES]: 没有那个文件或目录”错误

项目场景

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})
  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

后厂村路蔡徐坤

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值