Reputation: 80
I created a ROS package and added to the CMakeLists.txt the relevant lines to create an executable.
add_executable(exe_name src/file.cpp)
target_link_libraries(exe_name $LIBRARIES)
When I run catkin_make
in the root of the workspace the executable is generated in WORKSPACE/build/PACKAGE_NAME/
instead of in
WORKSPACE/devel/lib/PACKAGE_NAME/
The problem is now when I run rosrun PACKAGE_NAME exe_name
the executable name (exe_name) is not found. Any ideas why this might happen?
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})
Upvotes: 3
Views: 6063
Reputation: 5017
The catkin_package
macro is missing in your CMakeLists.txt. Add this after the find_package section:
###################################
## 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
)
(You can remove the comments of course, I just copied the whole block so that the description is contained)
Upvotes: 2