I know that a similar question has been asked before, but none of the suggestions have helped.
I am trying to compile an OpenCV project using C++ in Ubuntu 15.10. I can run the project correctly in Netbeans. But I am supposed to send this to someone who will be using the command line. I can compile the program with the line:
g++ -ggdb -o convert *.cpp \`pkg-config --cflags --libs opencv\`
Where convert
is the chosen name for the executable. There are no problems after executing this line. But when I run
./convert "image1.tif" "image2.tif"
I get:
./convert: error while loading shared libraries: libopencv_imgcodecs.so.3.2: cannot
open shared object file: No such file or directory
In my .cpp files, I have:
#include "/usr/local/include/opencv2/highgui/highgui.hpp"
The file libopencv_imgcodecs.so.3.2
is in my /usr/local/lib
folder. I tried putting -L/usr/local/lib
in the command line, but this did not help. Perhaps this file path needs to go in a specific order in the command line? The order mattered for the pkg-config --cflags --libs opencv
, which had to come after the -o convert *.cpp.
Just for convenience, as the first comment said, you just need:
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
if your CMAKE_INSTALL_PREFIX=/usr/local
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With