5

I've just installed OpenCV on my Debian machine, and I'm having issues with it. I followed the install guide on the Wiki. Trying to compile the examples gives what appears to be a successful compile, however trying to run them ends up throwing an error:

fagg@hubble:~/src/OpenCV-2.3.1/samples/cpp$ g++ -Wall em.cpp
-lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video
-lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect
-lopencv_contrib -lopencv_legacy
fagg@hubble:~/src/OpenCV-2.3.1/samples/cpp$ ./a.out
./a.out: error while loading shared libraries: libopencv_core.so.2.3:
cannot open shared object file: No such file or directory
fagg@hubble:~/src/OpenCV-2.3.1/samples/cpp$ pkg-config opencv
--libs-L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui
-lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d
-lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
fagg@hubble:~/src/OpenCV-2.3.1/samples/cpp$

But even doing this doesn't work:

fagg@hubble:~/src/OpenCV-2.3.1/samples/cpp$ g++ -Wall em.cpp
`pkg-config opencv --cflags --libs`
fagg@hubble:~/src/OpenCV-2.3.1/samples/cpp$ ./a.out
./a.out: error while loading shared libraries: libopencv_core.so.2.3:
cannot open shared object file: No such file or directory
fagg@hubble:~/src/OpenCV-2.3.1/samples/cpp$

I think there's an issue with the linking, but I'm not quite sure what's going on. This is a completely fresh install of OpenCV - I've never had it on this machine before. Does anyone have any ideas?

NOP
  • 864
  • 1
  • 12
  • 26
  • 5
    From you `pkg-config` output it looks like the library resides in `/usr/local/lib`. What happens when you try `LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib ./a.out`? – another.anon.coward Mar 12 '12 at 04:26
  • 1
    Gah! Of course! I ran an ldconfig and that fixed it. Which is strange, because when I tried it yesterday it didn't work. Thanks a bunch! – NOP Mar 12 '12 at 04:42

1 Answers1

19

Ran

sudo ldconfig

Suggested by anon.coward

Jumabek Alikhanov
  • 2,305
  • 3
  • 21
  • 21
NOP
  • 864
  • 1
  • 12
  • 26