1

I installed OpenCV on my Raspberry, I wrote the first sample program (http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html). It compile correctly, but if executed from Code::Blocks it gave an error because miss an argument that must be given from CLI.

./First image.jpg

The program should only show an image in a window. The problem is that when I try to execute it from CLI I get an error.

./First: error while loading shared libraries: cv2.so: cannot open shared object file: No such file or directory.

What should I do? Where could I find cv2.so?

3

cv2.so should be someplace within the build directory. You can use find <build folder> -name cv2.so to locate it.

In order to get ./First image.jpg to run sucessfully you'll need to ensure that the binary knows where it can find the library file. You can do this two ways:

  • Any binary under linux automatically looks in the current directory for its dynamic libraries. By making a symlink from cv2.so to the directory the binary is in, ln -s ~/path/to/cv2.so ., it will be found.
  • Instead of making the library be the binary it will look, you can tell the binary to look someplace else by using the LD_LIBRARY_PATH environment argument, e.g. LD_LIBRARY_PATH=~/path/to/ ./First image.jpg.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.