Ask Your Question

How can I generate pkg-config files for my package?

asked 2018-07-23 02:54:20 -0600

pepijndevos gravatar image

updated 2018-07-23 05:58:04 -0600

I have a Catkin package that generates several binaries and libraries, but unlike some other packages, pkg-config can't find them.

ROS seems to have set the path to both my Kinetic installation, as well as my workspace.


When I ask pkg-config --list-all about it, it does know about all of the ROS libraries, and also about things I installed in my own workspace, like joy and uuid. But it does not find the libraries I wrote myself.

I went over to the CMakeLists.txt of joy to see if I could find anything obvious that has to be done to generate the correct files, but can't see anything. There is no .pc file in the repo either. I also tried to google around, but all results are about using external packages inside ROS, not about using ROS package outside it.

Currently I'm just doing this, but that apparently does not get you any pkg-config files. Full source:


When I run this, there is no output

$ pkg-config --list-all | grep -i skill

So what is the correct way to tell pkg-config about my library, just like joy and uuid?

edit retag flag offensive close merge delete


This should be done automatically for your package, but it will depend on you properly setting up (and ordering) your CMakeLists.txt. Please add that to your question so we can take a look.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-23 04:19:16 -0600 )edit

I've added a link to the source code: I'm trying to link the Skill library that I added.

pepijndevos gravatar image pepijndevos  ( 2018-07-23 05:57:16 -0600 )edit

That's quite a long CMakeLists.txt. I don't have time to check it all now, so I'll point you to wiki/catkin/CMakeLists.txt. The ordering and contents of statements on that page should give you some things to check.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-23 07:13:20 -0600 )edit

Suggestion: try to create an MWE and see if that works with pkg-config (it should). Then do a diff (could be a mental one) between your MWE and your roboteam_tactics package.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-23 07:19:03 -0600 )edit

Btw: this is no longer used by anything. It's something that the rosbuild system relied upon. Unless you have some custom tools that use it, it can probably be removed.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-23 07:20:04 -0600 )edit

Ah! Catkin makes a pkg-config entry for the whole roboteam_tactics, rather than any individual libraries I define. If I add Skill to catkin_package(), I can do pkg-config --libs roboteam_tactics -Lsomewhere/lib -lroboteam_tactics_analysis -lSkill. Is there a way to have skill on its own?

pepijndevos gravatar image pepijndevos  ( 2018-07-23 08:48:00 -0600 )edit

The pkg config file is generated for the entire CMake project, in this case for your ROS package. I don't believe it's possible to generate a config file for each separate target, no.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-23 11:26:33 -0600 )edit

Ok. Thanks!

pepijndevos gravatar image pepijndevos  ( 2018-07-23 11:27:34 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-23 11:35:43 -0600

gvdhoorn gravatar image

(I'm going to post this as an answer, but it's really more a summary of the discussion in the comments)

What you're asking for is not possible afaik: Catkin will only generate a single pkg config file for a ROS package. It's not possible to have it generate multiple files (for separate targets fi).

It's actually the catkin_package(..) call that (eventually) generates the config file and the config file generated will contain information on all libraries added to the LIBRARIES argument of the catkin_package(..) call (and conversely: if you don't list a library there, it will not be mentioned in the pkg config file).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-07-23 02:54:20 -0600

Seen: 2,311 times

Last updated: Jul 23 '18