Ask Your Question

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

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

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


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


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

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

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

dornhege gravatar image

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

edit flag offensive delete link more


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

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: 2013-11-25 11:45:48 -0500

Seen: 128 times

Last updated: Nov 26 '13