Ho to export external library
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
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?