Ask Your Question

Catkin - Cannot Find Custom Library I Made In Another Package

asked 2014-01-13 14:54:36 -0500

trianta2 gravatar image

updated 2014-01-28 17:19:01 -0500

ngrennan gravatar image


I created a custom library in my package pack_A like so:

   INCLUDE_DIRS include
   LIBRARIES mycustomlib

add_library(mycustomlib STATIC src/customsource.cpp)
target_link_libraries(mycustomlib ${other_libs})

And then in another package, I include pack_A and try to explicitly link against mycustomlib it instead of using {catkin_LIBRARIES} like so:

find_package(catkin REQUIRED COMPONENTS pack_A) 
add_library(liblinktest src/test.cpp) 
target_link_libraries(liblinktest mycustomlib) 

However I get the error:

error: cannot find -lmycustomlib

Can anyone help me out? I do not want to link against {catkin_LIBRARIES}. Thanks for your time.

EDIT: This... actually does build. However, I've been developing within QtCreator, and for some reason I get the "cannot find ..." error in QtCreator, but when I build via catkin_make, it builds just fine and runs.

Does anyone know why there is such a discrepancy between QtCreator and catkin_make here?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-14 00:38:37 -0500

Wolf gravatar image

If you do not use catkin you do have to make cmake/your linker aware of where your is placed (as long as it is not in /usr/lib or something like that). You can do this using the link_directories() command

link_directories( /path/to/my/custom/lib )

Note that catkin usually puts the shared library files into <catkin_workspace>/devel/lib/ ...

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

1 follower


Asked: 2014-01-13 14:54:36 -0500

Seen: 1,884 times

Last updated: Jan 14 '14