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

Compiling and adding a static library

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

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

Comments

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

zweistein gravatar image zweistein  ( 2015-11-19 03:29:44 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

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

Comments

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 image JanOr  ( 2015-08-31 10:13:21 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 2,226 times

Last updated: Aug 31 '15