Ask Your Question

Compiling and adding a static library

asked 2015-08-31 06:53:28 -0500

JanOr gravatar image

Hello, I have a question regarding a library. I want to use a library within my catkin package (I use jade). With the following structure: In the src folder of my project I have added the library folder lib. catkinws/src/Project/lib/ The external library has following structure

  • catkinws/src/Project/lib/clib2add/Makefile ->The Makefile of the external library
  • catkinws/src/Project/lib/clib2add/src ->The Sourcecode of the external library
  • catkinws/src/Project/lib/clib2add/libs/staticlib2add.a ->The static library produced with the Makefile

So my question: How can I compile the external c library with the given Makefile? How can I add the resulting static library in my catkin project? (somehow i have to define its source and link it to the project target, unfortunately I could no succeed with target link libraries)

Do you have any idea how my CMakeLists and the Package.xml should look like? Thank you very much!

edit retag flag offensive close merge delete


Did you managed to solve this linking issue, because I need to do the same thing.

zweistein gravatar imagezweistein ( 2015-11-19 03:29:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-31 08:41:30 -0500

Oded gravatar image

I would try in the CMakeLists:

add_executable(node_name src/node_code.cpp ...)
add_library(mylib lib/staticlib2add.cpp)
target_link_libraries(mylib ${OpenCV_LIBS} ${catkin_LIBRARIES} ${Boost_LIBRARIES} ...)
target_link_libraries(node_name mylib ${OpenCV_LIBS} ${catkin_LIBRARIES} ${Boost_LIBRARIES} ...)
edit flag offensive delete link more


It is a static library with the ending .a Therefore I guess it should be somehow a build dependent and cannot be added via add_library(mylib lib/staticlib2add.cpp)

JanOr gravatar imageJanOr ( 2015-08-31 10:13:21 -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

1 follower


Asked: 2015-08-31 06:53:28 -0500

Seen: 1,208 times

Last updated: Aug 31 '15