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

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 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. ( 2016-01-21 05:23:38 -0600 )edit Seeing your other question, can you describe how you setup your workspace(s), and how you interact with them? ( 2016-01-21 05:28:13 -0600 )edit 3 Answers Sort by » oldest newest most voted 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. more 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. 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 ( 2016-01-21 06:58:45 -0600 )edit 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}
)

more