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

Using catkin to install libraries

asked 2016-04-05 23:00:16 -0600

badrobit gravatar image

I currently have a series of 3rd party libraries that I want to package for easier building and use. The idea is that they are each contained in a catkin_project file that looks like this: (Note: libboost is just an example package)


cmake_minimum_required( VERSION 2.8.3 )

project( lib_boost )


install( DIRECTORY include/

install( DIRECTORY lib/


<package format="2">



    <description> -- </description>

    <maintainer email="--"> -- </maintainer>




When I try to include this into the main system I do it in the following way: cmake_minimum_required( VERSION 2.8.3 )

project( project_ros CXX )

find_package( catkin REQUIRED COMPONENTS    lib_boost
                                            message_runtime )

## Add all of the include directories defined by the packages listed above
include_directories( include ${catkin_INCLUDE_DIRS} )

catkin_package( CATKIN_DEPENDS  message_runtime
                INCLUDE_DIRS  )

        src/main.cpp )

## Create the linis_ros executable 
add_executable( project_ros ${ROS_PROJECT_SOURCE} )


<?xml version="1.0"?>

<package format="2">




    <maintainer email="--">--</maintainer>






The output of both catkin_make -j1 and catkin_make install -j1 both throw the following error:

No such file or directory

When I look in the install directory there is nothing in the include portion but if i remove my package and then run catkin_make install the libraries will put their files into the proper spots but when i replace my package and run catkin_make it is still unable to find the header files I know are in the proper locations.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-06 00:01:39 -0600

ahendrix gravatar image

install rules are valid for install space, but they're not the whole picture. cmake also requires Package-config.cmake files which tell it how to find your package, which libraries to include, etc.

When building with catkin_make, you're building in a development workspace, which is faster than running all of the install rules, but it also means that files aren't installed.

The catkin_package() call is designed to address both of these - it generates the requisite files so that other cmake files can find this project, and it allows other packages in your devel space to find your project.

To use catkin_package() correctly, you need to give it your install directory, any libraries that downstream packages should link to, any external dependencies that downstream projects need when building, and any catkin dependencies that downstream projects need when building.

For example (and I'm making things up because you're making things up), if your package has all of its includes in the include directory, and it builds a library called libmypacakge (with a cmake target name of mypackage), and it depends on roscpp (catkin package) and ffmpeg (external package), then your catkin_package call would look something like:

    INCLUDES include
    LIBRARIES mypacakge
    DEPENDS ffmpeg # same name you used to find the package earlier

If your package has headers that include the roscpp headers and the ffmpeg headers, this guarantees that their include directories will be on the include path for anyone who uses your library. (same for libraries).

edit flag offensive delete link more


Thank you so much by adding the INCLUDES portion to the catkin_package for the libraries I am installing it can now find them.

I hadn't quite grasped that I needed this in the catkin_package call to let other package know about it.

badrobit gravatar image badrobit  ( 2016-04-06 00:15:57 -0600 )edit

Is it possible to use the catkin_package() call to have the system provide libraries even if you don't build them and are just redistributing them?

badrobit gravatar image badrobit  ( 2016-04-06 11:31:35 -0600 )edit

Yes, but it's a little more complicated. See for an example.

ahendrix gravatar image ahendrix  ( 2016-04-06 12:35:11 -0600 )edit

Question Tools

1 follower


Asked: 2016-04-05 23:00:16 -0600

Seen: 2,471 times

Last updated: Apr 06 '16