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

What causes a library (.so) to be copied to devel/lib

asked 2016-01-21 04:28:58 -0500

martin1412 gravatar image

updated 2016-01-21 05:39:51 -0500

Hi guys,

I've got a project comprising approximately 30 packages. Some of these packages define libraries in the CMakeLists, using the add_library and target_link_libraries functions. I am wondering why only some of these packages create shared objects in devel/lib while others aren't.

Example: I've got a package (for simplicity say package "a") which defines a library. This package is referenced as <runtime_dep> by another package (b). Sadly, when running catkin build, no shared object is copied to devel/lib, resulting in runtime failure in node b.

EDIT: Thank you for your answers, but that doesn't seem to be what I am looking for.

I am using catkin_tools to build my project. I configure my build with catkin config --no-install, hence no install targets are executed.

Still, catkin puts some libraries in devel/lib. If I look at the $LD_LIBRARY_PATH after the build, I can see that the devel/lib directory is included there. My problem is that I don't know which statement causes a defined library to be copied there at build time.

All packages define the libraries using add_library, target_link_libraries and catkin_package(... LIBRARIES <xyz>), still some of them are not copied to devel/lib

Package definition of a package which doesn't create a shared object in devel/lib:

... 
add_library(m_controllers    
     src/general.cpp    
     src/passthrough.cpp )

add_dependencies(m_controllers ${catkin_EXPORTED_TARGETS}) 
target_link_libraries(m_controllers ${catkin_LIBRARIES})

catkin_package(    
CATKIN_DEPENDS
....    
INCLUDE_DIRS include    
LIBRARIES m_controllers 
) 
...
edit retag flag offensive close merge delete

Comments

To add to @Akif's answer: note that for things to work in a devel workspace, you don't actually need to have any install(..) rules, just properly setup catkin_package(.. LIBRARIES ..) statements.

gvdhoorn gravatar image gvdhoorn  ( 2016-01-21 05:23:38 -0500 )edit

Seeing your other question, can you describe how you setup your workspace(s), and how you interact with them?

gvdhoorn gravatar image gvdhoorn  ( 2016-01-21 05:28:13 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
3

answered 2016-01-21 05:13:33 -0500

Akif gravatar image

In addition to @F.Brosseau's answer, you can check this page for a general how-to on Building and installing C++ libraries and headers.

edit flag offensive delete link more
3

answered 2016-01-21 06:35:50 -0500

gvdhoorn gravatar image

Order matters in catkin-ised CMakeLists.txt, please re-order the statements to follow the order given in wiki/catkin/CMakeLists.txt - Overall Structure and Ordering.

edit flag offensive delete link more

Comments

The problem seems to be related to the order of commands in my CMakeLists.txt Thank you gvdhoorn!

After moving the add_library, add_dependencies and target_link_libraries statements below catkin_package, the .so file was created in devel/lib

martin1412 gravatar image martin1412  ( 2016-01-21 06:58:45 -0500 )edit
1

answered 2016-01-21 04:39:52 -0500

F.Brosseau gravatar image

You can try to add the following at the end of your CMakeLists.txt file :

install(TARGETS
   a
   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
   )
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-01-21 04:28:58 -0500

Seen: 2,862 times

Last updated: Jan 21 '16