ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Create and link ROS library

asked 2015-03-10 07:55:07 -0500

cpiury gravatar image

Hi, I have implemented a ROS library and I have "" file. Now I want to use this library in another external project and I don't know how to do this. I have in my new project a CMakeLists.txt and in it I link my library in the following way:

ADD_EXECUTABLE(foo main.cpp)


But this doesn't work and I get undefined reference to the implemented functions. My new project is not created with "catkin_init_workspace" since it's not a 100% ROS project, so... If I want to use my ros library, my new project (that is not a 100% ROS project, only uses my ros library for 2 little tasks) must be created with the catkin_init_workspace and create in it a node that uses this library? or are there any way to use my ros library into my new project without the catkin_workspace / node architecture?, I mean, creating something like:


And inside CMakeLists.txt something like:

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-10 12:53:00 -0500

William gravatar image

Your ROS package you are trying to use in your non-ROS CMake project generates CMake files. You can just do:

find_package(my_ROS_package REQUIRED)
target_link_libraries(executable ${my_ROS_package_LIBRARIES})

in the non-ROS CMake project you have. Just make sure to source the setup.bash file generated from building your ROS package's workspace, otherwise it might not be on the CMAKE_PREFIX_PATH.

edit flag offensive delete link more

Question Tools


Asked: 2015-03-10 07:55:07 -0500

Seen: 762 times

Last updated: Mar 10 '15