OpenCV:“libopencv_core.so.2.3:无法打开共享对象文件:没有这样的文件或目录”

OpenCV:“libopencv_core.so.2.3:无法打开共享对象文件:没有这样的文件或目录”

问题描述:

我刚刚在我的Debian计算机上安装了OpenCV,我遇到了问题。我按照Wiki上的安装指南。试图编译例子给出了似乎是一个成功的编译,但试图运行它们最终抛出一个错误:

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$

我认为链接有问题,但我不太确定发生了什么。这是一个完全新安装的OpenCV - 我从来没有在这台机器上。是否有任何想法?

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?

Ran

sudo ldconfig

建议者anon.coward

Suggested by anon.coward