当前位置:网站首页>ROS中编译通过但是遇到可执行文件找不到的问题
ROS中编译通过但是遇到可执行文件找不到的问题
2022-08-03 11:45:00 【MrandMis】
编写一个ros package,catkin_make
编译后却无法Tab
补全包内的节点名称双击Tab
甚至没有任何可执行节点信息,手动写全也出现如下错误:
[rosrun] Couldn't find executable named XXXXXXXXXXXX
问题出在add_executable()以及target_link_libraries()出现的位置。
值得注意的是第一段代码的位置一定要在第二段之前,否则在devel/lib里面是无法生成编译后的文件的。
# Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
add_executable(basic_shapes src/basic_shapes.cpp)
target_link_libraries(basic_shapes ${catkin_LIBRARIES})
add_executable(points_and_lines src/points_and_lines.cpp)
target_link_libraries(points_and_lines ${catkin_LIBRARIES})
最后位置正确的效果如下述代码。
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES using_markers
# CATKIN_DEPENDS roscpp visualization_msgs
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/using_markers.cpp
# )
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## 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/using_markers_node.cpp)
## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkin_LIBRARIES}
# )
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# catkin_install_python(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
add_executable(basic_shapes src/basic_shapes.cpp)
target_link_libraries(basic_shapes ${catkin_LIBRARIES})
add_executable(points_and_lines src/points_and_lines.cpp)
target_link_libraries(points_and_lines ${catkin_LIBRARIES})
再次catkin_make就可以看到结果了。
边栏推荐
猜你喜欢
随机推荐
FR9811S6 SOT-23-6 23V,2A同步降压DC/DC转换器
增加WebView对localStorage的支持
浅谈SVN备份
使用.NET简单实现一个Redis的高性能克隆版(一)
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
深度学习中数据到底要不要归一化?实测数据来说明!
-树的高度-
云原生 Dev0ps 实践
技术总监需要会些什么?也太难了!
LeetCode-142. 环形链表 II
c语言进阶篇:内存函数
Vs 快捷键---探索不一样的编程
[论文阅读] (23)恶意代码作者溯源(去匿名化)经典论文阅读:二进制和源代码对比
一个扛住 100 亿次请求的红包系统,写得太好了!!
Matlab学习13-图像处理之可视化GUI程序
899. 有序队列 : 最小表示法模板题
我在母胎SOLO20年
html网页如何获取后台数据库的数据(html + ajax + php + mysql)
SmobilerService 推送实现
MySQL - 2059 - Authentication plugin ‘caching_sha2_password‘ cannot be loaded