我创建了一个ROS包并将相关行添加到CMakeLists.txt中以创建可执行文件。
add_executable(exe_name src/file.cpp)
target_link_libraries(exe_name $LIBRARIES)
当我在工作区的根目录中运行catkin_make
时,可执行文件在WORKSPACE/build/PACKAGE_NAME/
中生成
而不是
WORKSPACE/devel/lib/PACKAGE_NAME/
问题是,当我运行rosrun PACKAGE_NAME exe_name
时,找不到可执行文件名(exe_name)。有什么想法可能会发生吗?
cmake_minimum_required(VERSION 2.8.3)
project(flea3ros)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
sensor_msgs
cv_bridge
image_transport
)
find_package(OpenCV 2)
include_directories(
${catkin_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
/usr/include/flycapture
)
add_executable(flea3syncros src/asyncRos.cpp)
add_executable(flea3ros src/GigEGrabEx.cpp)
add_executable(flea3config src/GigEConfig.cpp)
add_executable(saveImages src/save_images.cpp)
target_link_libraries(flea3ros ${catkin_LIBRARIES} ${OpenCV_LIBS} flycapture)
target_link_libraries(flea3syncros ${catkin_LIBRARIES} ${OpenCV_LIBS} flycapture)
target_link_libraries(flea3config ${catkin_LIBRARIES} ${OpenCV_LIBS} flycapture)
target_link_libraries(saveImages ${catkin_LIBRARIES} ${OpenCV_LIBS})
答案 0 :(得分:1)
CMakeLists.txt中缺少catkin_package
宏。在find_package部分之后添加:
###################################
## 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 you 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 compute_cdist
# CATKIN_DEPENDS roscpp visualization_msgs robot_model_helper compute_cdist
# DEPENDS assimp Eigen mlpack
)
(你可以删除评论当然,我只是复制整个块以便包含描述)