ros2踩坑记
程序员文章站
2022-07-14 22:18:18
...
在构建一个激光雷达点云的包时,遇到一个很奇怪的问题,包能构建成功,但是使用ros2 run 时,无法用Tab键补全可执行文件名(包名是可以补全的),手动输入 ros2 run <package_name> <executable_name> 会提示:
No executable found
这个问题困扰了我好久,最终在这里 找到了原因。
原来我的CMakeLists.txt是这样的(部分)
install(
DIRECTORY include/
DESTINATION include
)
install(
DIRECTORY launch/
DESTINATION share/launch)
install(TARGETS cloud_node
EXPORT export_cloud_node
RUNTIME DESTINATION cloud_node/bin/
ARCHIVE DESTINATION cloud_node/lib/static/
LIBRARY DESTINATION cloud_node/lib/shared/
INCLUDES DESTINATION cloud_node/include/
)
install(TARGETS
cloud_node
DESTINATION lib/cloud_node
)
修改后
install(
DIRECTORY include/
DESTINATION include
)
install(
DIRECTORY launch/
DESTINATION share/launch)
install(TARGETS cloud_node
EXPORT export_cloud_node
RUNTIME DESTINATION lib/${PROJECT_NAME}
ARCHIVE DESTINATION cloud_node/lib/static/
LIBRARY DESTINATION cloud_node/lib/shared/
INCLUDES DESTINATION cloud_node/include/
)
install(TARGETS
cloud_node
#executables must be installed at lib/{PROJECT_NAME},otherwise ros2 run can't find it
DESTINATION lib/${PROJECT_NAME}
)
可执行文件的安装位置改了以后就可以找到可执行文件了