Ask Your Question

How to export a debug and release library?

asked 2014-11-18 09:18:02 -0500

Boris_il_forte gravatar image

updated 2014-11-20 14:35:42 -0500

I have package A in workspace1, and i build the package using:

catkin_make -DCMAKE_BUILD_TYPE=Debug

When I try to compile package B in workspace2 using:

catkin_make -DCMAKE_BUILD_TYPE=Debug

Build fails with message:

CMake Error at /path/AConfig.cmake:141 (message):
  Project 'B' tried to find library 'target_inside_A''.  The library is
  neither a target nor built/installed properly.  Did you compile project
  'A'? Did you find_package() it before the subdirectory containing
  its code is included?

same issue when building with catkin_make_isolated a workspace with both packages inside (catkin_make compilation runs clean).

I don't know if this behaviour is by catkin design or if it's a bug, or if it's all my fault.

I'm using ROS indigo on debian, compiled by source.

I've also tested in ROS groovy on ubuntu 12.10.

edit retag flag offensive close merge delete


I don't suppose it would be possible for you to post your code even, if it is anonymized, or a minimal example which reproduces this? Unfortunately, I can't imagine what the issue is or what to recommend without the contents of your CMakeLists.txt for each.

William gravatar image William  ( 2014-11-18 18:35:42 -0500 )edit

I'm so sorry, I missed to tell that you should set a debug postfix to see the issue.

i was missing the point because the library is huge, and I've only worked on the catkinization.

here is a minimal example of the setup:

Boris_il_forte gravatar image Boris_il_forte  ( 2014-11-19 07:33:19 -0500 )edit

ps: i don't know how to upload files, so i've used dropbox... if there is a better way to share the workspace tell me...

Boris_il_forte gravatar image Boris_il_forte  ( 2014-11-19 08:03:20 -0500 )edit

I can compile your example with ROS Indigo perfectly fine - also when setting the build type to "Debug". Since groovy has been EOLed I don't maintain a VM to test with it anymore.

Dirk Thomas gravatar image Dirk Thomas  ( 2014-11-19 11:43:31 -0500 )edit

Have you tried catkin_make_isolated -DCMAKE_BUILD_TYPE=Debug? Please consider to run it on a clean workspace to avoid side effects (it seemes that if the release libraries exists, the linker uses them instead of Debug version). With catkin_make it works perfectly, the problem is the isolation...

Boris_il_forte gravatar image Boris_il_forte  ( 2014-11-19 12:20:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-11-19 13:02:15 -0500

Dirk Thomas gravatar image

updated 2014-11-20 12:23:56 -0500

The problem is that your package A exports the library aaa:

catkin_package(LIBRARIES aaa)

But when package B tries to find it it obviously does not exist.

Since catkin is unaware of the renaming (you could even install the library under a totally different name, e.g. it can't make any assumptions.

Therefore you need to change the exported library name to how it is actually called:

catkin_package(LIBRARIES aaa_d)


If you extend your question to "how to export a debug and release library" the answer changes to:

You have to export both library names and in order to differentiate them use the CMake build configuration keywords ( ) before them:

catkin_package(LIBRARIES debug aaa_d optimized aaa)

Again, it wouldn't help if catkin would "be aware of the CMAKE_<conf>_POSTFIX variables". Simply because the name you give your library does not need to be the same after you installed it. And catkin must be able to resolve the installed library as well. That's why you must specify the name of the (potentially renamed installed) library explicitly.

edit flag offensive delete link more


This doesn't work... Obviously fixes the debug build, but now you have an issue with the release build. The problem is that catkin should be aware of the CMAKE_<conf>_POSTFIX variables when generating the Find<package> cmake module. using debug suffix is widely used in libraries like g2o and qt.

Boris_il_forte gravatar image Boris_il_forte  ( 2014-11-20 04:32:43 -0500 )edit

Changed title. Ok, now the system works, still the build fails the first time, because both library are needed to build. However, the library links properly...

Boris_il_forte gravatar image Boris_il_forte  ( 2014-11-20 16:28:29 -0500 )edit

You could put the libraries into a variable conditional (on them getting built) and pass that to catkin_package(LIBRARIES ...).

William gravatar image William  ( 2014-11-20 16:50:47 -0500 )edit

Which build fails the first time?

Dirk Thomas gravatar image Dirk Thomas  ( 2014-11-20 16:57:05 -0500 )edit

I would guess the first one (no matter which is first). I think it is because he cannot do build type as Release and Debug at the same time. He is relying on that mechanism to choose which library to build, he isn't building both always, so one is always non existent on the first build.

William gravatar image William  ( 2014-11-20 17:17:35 -0500 )edit

@Wiliam: you mean if(debug) ... else() ... ? @Dirk: any build (relase/debug). an this time also with catkin make. Why this happens is obvious (specifing the library in such a way means that BOTH should be present always). @Wiliam: exactly. just using CMAKE_DEBUG_POSTFIX...

Boris_il_forte gravatar image Boris_il_forte  ( 2014-11-20 17:23:45 -0500 )edit

You can either build both libraries and export both using the build configuration keywords OR you build only one library and (however you call it) export that specific library name only.

Dirk Thomas gravatar image Dirk Thomas  ( 2014-11-20 17:27:28 -0500 )edit

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: 2014-11-18 09:18:02 -0500

Seen: 982 times

Last updated: Nov 20 '14