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

时间:2012-03-12 03:55:22

标签: c++ opencv

我刚刚在我的Debian机器上安装了OpenCV,我遇到了问题。我按照Wiki上的安装指南进行操作。尝试编译示例会给出看似成功的编译,但是尝试运行它们最终会抛出错误:

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$

但即使这样做也行不通:

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安装 - 我之前从未在这台机器上安装过它。有没有人有任何想法?

1 个答案:

答案 0 :(得分:19)

sudo ldconfig

anon.coward建议