Friday, February 7, 2014

linking external c++ library to ROS

Hello,
I have an external .cpp library that requires both the following libraries: atlas,llpack and lblas
Now if for example, I compile using terminal (on the same machine) I can use the following:
g++ main.cpp hmm.cpp -I /usr/include/atlas -L /usr/lib64/atlas/ -llapack -lblas
This will work. I don't know how to include these libraries into the CMake list in ROS. I have, currently, the following:
rosbuild_add_executable(build1 src/hmm.c)
What would I have to add into my CMake list to make this work?
Thanks
retag flag offensive close delete

1 answer

1
answered 7 hours ago
Wolf gravatar image
link_directories( /usr/lib64/atlas )
equivalent to -L /usr/lib64/atlas of gcc/g++
And after :
rosbuild_add_executable(build1 src/hmm.c)
you put
target_link_libraries( build1 lapack blas )
equivalent to -llapack -lblas
Note: First arg of target_link_libraries is the previously defined target to link.
Note: no prepended -l in target_link_libraries, i e. if your external lib is named libmy_lib.so you just add my_lib to target_link_libraries
flag offensive delete link

Your Answer

No comments:

Post a Comment