0

Rosanswers logo

Hi,

I'm pretty sure that this question has been answered already, but for some reason I'm not able to find the right solution, and currently I am confused by the results I read. So I hope you can point me in the right direction.

I have created a library in one package, using the install() command of the cmakelists. This Library does appear in my workspaces devel/lib, as "libMYLIB.so". I want to use this library within another package, but I'm not exactly sure how. I tried it with just using

target_link_libraries(${PROJECT_NAME}_node

${catkin_LIBRARIES}

MYLIB )

But i get the error

/usr/bin/ld: cannot find -lMYLIB collect2: error: ld returned 1 exit status

I tried using

link_directories( ${CATKIN_PACKAGE_LIB_DESTINATION} )

, since this directory was used to install the library, but to no effect. What should I do, or where can I find the definite answer?


Originally posted by Jan Fox on ROS Answers with karma: 13 on 2017-11-20

Post score: 0

1 Answers1

0

Rosanswers logo

http://docs.ros.org/kinetic/api/catkin/html/howto/format2/building_libraries.html

In the library building package be sure to have your library listed as something other projects can use:

catkin_package(
               ...
               LIBRARIES MYLIB)

Put the name of the package you built the library into a <build_depend> in package.xml and put it into in the list of packages in find_package() in your CMakeLists.txt. The actual name of the library doesn't matter (just the name of the package that built it), it will get included in ${catkin_LIBRARIES}.


Originally posted by lucasw with karma: 8729 on 2017-11-20

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Jan Fox on 2017-11-20:
That was easier than expected. Thanks. I was sure I tried this, but maybe I made a spelling error.

Lucas Walter
  • 3,337
  • 1
  • 14
  • 19