Ask Your Question

adding shared objects to catkin package [closed]

asked 2015-05-08 07:41:23 -0600

Reiner gravatar image

updated 2015-05-11 04:37:45 -0600

Hi, i'm writing a node that has to call some functions from a .so library. The node called test_service_server has to use functions from This lib is NOT a catkin lib, it was created outside of ROS entirely.

inside my CMakeLists.txt i have the following:

include_directories( ${catkin_INCLUDE_DIRS} lib)
add_executable(test_service_server src/test_service_server.cpp)
target_link_libraries( test_service_server ${catkin_LIBRARIES} ${EXTRALIB_BIN})

I still get the error: no rule to make target.

Can someone give me a few tipps about linking shared objects to catkin packages?

EDIT: Just to explain my problem better: I have a shared object lib with ca 200 functions my node needs. ( in the /lib folder of the package) These functions are described in header files (ca. 10, in the /include folder of the package).

I can't get the source of this library to try and build it as a catkin lib. how do i properly link my .so in CMakeLists.txt?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Reiner
close date 2015-06-25 01:19:56.548537


FYI: found a solution: target_link_libraries( test_service_server ${catkin_LIBRARIES} ${PROJECT_SOURCE_DIR}/lib/ this use of target link libraries works perfectly, in case someone stumbles upon the question.

Reiner gravatar imageReiner ( 2015-06-02 03:22:13 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-05-11 04:53:06 -0600

gvdhoorn gravatar image

Even though @Wolf's answer should work for you, I'll add some references to earlier questions that asked the same thing:

The accepted answer to the second question also has some links to pkgs that do the same thing.

edit flag offensive delete link more


thanks, those two links were a huge help for me:)

Reiner gravatar imageReiner ( 2015-05-11 08:33:02 -0600 )edit

answered 2015-05-08 15:57:26 -0600

Wolf gravatar image

I assume its a precompiled lib you have copied to your project folders /lib directory. If so you need to

link_directoriest(  ${PROJECT_SOURCE_DIR}/lib )

 target_link_libraries( test_service_server ${catkin_LIBRARIES} test )

Note: link_drectories specifies the path for your libs target_link_libraries takes the library names without lib prefix and .so postfix.

Also note that this is only valid if its a somehow outside catkin created lib. If catkin creates the lib it won't put them in the lib folder of your project but into the devel/lib folder of your workspace so the workaround is different then...

edit flag offensive delete link more


Yes, it is a precompiled lib, made outside of catkin. i tried your method with link_directories, unfortunately with the result: /usr/bin/ld: cannot find -ltest

Reiner gravatar imageReiner ( 2015-05-11 04:19:12 -0600 )edit

sorry for the late comment, i've got it running, though i still needed both the lib prefix and the so postfix

Reiner gravatar imageReiner ( 2015-06-02 03:20:24 -0600 )edit

Question Tools


Asked: 2015-05-08 07:41:23 -0600

Seen: 725 times

Last updated: May 11 '15