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

Ho to export external library

asked 2013-11-25 11:45:48 -0500

updated 2013-11-26 01:09:44 -0500

I created a library in OpenCV where I implemented some image processing. The *.so file i copied to /usr/local/lib. I'm still using Fuerte. I want to link on of my node with this library to use my functions. What is the best way to link the library?

First I complied the library:

$ g++ ``pkg-config --cflags opencv`` -o RailwayImageProcess.o -c RailwayImageProcess.c ``pkg-config --libs opencv``

$ g++ RailwayImageProcess.o -Wall -g -shared -o RailwayImageProcess.so

Than i copied the *.so to /usr/local/lib

I tired adding to my CMakeList.txt the folowing lines:

link_directories(/usr/local/lib)

target_link_libraries(${PROJECT_NAME} RailwayImageProcess)

Finally i run a cmake . and make But I get an error in Linking phase: Linking CXX executable bin/railDetect /usr/bin/ld: cannot find -lRailwayImageProcess collect2: ld returned 1 exit status make[2]: * [bin/railDetect] Error 1 make[1]: [CMakeFiles/railDetect.dir/all] Error 2 make: ** [all] Error 2

edit retag flag offensive close merge delete

Comments

What is your exact linking setup? Which libraries are involved. You have my_lib in the CMakeLists.txt, but you get an error on RailwayImageProcess. Do you have a dependency on that library?

dornhege gravatar image dornhege  ( 2013-11-25 22:29:46 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-11-26 00:17:32 -0500

fapofa gravatar image

Check for the lib prefix in your library name at linking phase.

edit flag offensive delete link more
0

answered 2013-11-26 01:02:39 -0500

dornhege gravatar image

Your compiled library is named RailwayImageProcess.so and you link my_lib in CMakeLists.txt. This obviously doesn't work if you use another name.

edit flag offensive delete link more

Comments

sorry the last row was an example how I linked the lib... not the actual command.

zweistein gravatar image zweistein  ( 2013-11-26 01:09:14 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-11-25 11:45:48 -0500

Seen: 201 times

Last updated: Nov 26 '13