0
$\begingroup$

Rosanswers logo

I am wondering how can I export an already built library within a package to make it available to other catkin packages.

Before with rosbuild this could be done by by using the cpp tag in the manifest. For instance:

<export>
<cpp lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lmylib" cflags="-I${prefix}/include"/>
</export>

As far as I understand this functionality has been replaced by the catkin_package() command. However, I have not found a clear way to make a prebuilt library within a catkin package visible to other catkin packages.

I have tried setting the prebuilt library as an imported library, but then when I do cmake it does not set it as a target visible by other packages. In CMakeLists.txt I have:

...
catkin_package(LIBRARIES mylib)
...
add_library(mylib STATIC IMPORTED)
set_target_properties(mylib PROPERTIES IMPORTED_LOCATION /path/to/mylib)

Any suggestions?


Originally posted by Francisco Vina on ROS Answers with karma: 101 on 2013-11-04

Post score: 1


Original comments

Comment by Dirk Thomas on 2013-11-06:
catkin_package(LIBRARIES ...) should be able to handle libraries build in your cmake project, absolute paths to an existing library as well as imported library targets. Please consider providing a link to the sources for further investigation.

Comment by Francisco Vina on 2013-11-21:
The package in question can be found in https://github.com/kth-ros-pkg/kvaser_canlib.git

I managed to get it working, but I had to do a hard copy of the library to the devel/lib folder. Any suggestions on how to do this in a more clean way?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

@Francisco Vina: As @Dirk Thomas mentioned, you can do so by providing the absolute path to the library so that you do not have to copy it to the devel space, and install it as usual to get it set up correctly in the install space.

Take a look at @William's answer here: http://answers.ros.org/question/66685/is-it-possible-to-create-a-catkin-package-to-provide-precompiled-libraries/

Example packages doing this a bit cleanly: https://github.com/ros-drivers/prosilica_gige_sdk https://github.com/utexas-bwi/rl_pursuit


Originally posted by piyushk with karma: 2871 on 2013-12-25

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.