1

这可能是一个菜鸟问题,但我已经被困了一段时间,我很感激任何帮助......

我已经能够安装opencv并使用终端运行示例应用程序而没有任何问题但是我想使用eclipse轻松管理我的项目......

我已按照此 [链接] http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html中的 opencv 教程给出的说明进行操作

我遵循了一切,但仍然出现以下错误

/usr/bin/ld: cannot find -llibopencv_calib3d
/usr/bin/ld: cannot find -llibopencv_contrib
/usr/bin/ld: cannot find -llibopencv_core
/usr/bin/ld: cannot find -llibopencv_features2d
/usr/bin/ld: cannot find -llibopencv_flann
/usr/bin/ld: cannot find -llibopencv_gpu
/usr/bin/ld: cannot find -llibopencv_highgui
/usr/bin/ld: cannot find -llibopencv_imgproc
/usr/bin/ld: cannot find -llibopencv_legacy
/usr/bin/ld: cannot find -llibopencv_ml
/usr/bin/ld: cannot find -llibopencv_nonfree
/usr/bin/ld: cannot find -llibopencv_objdetect
/usr/bin/ld: cannot find -llibopencv_photo
/usr/bin/ld: cannot find -llibopencv_stitching
/usr/bin/ld: cannot find -llibopencv_superres
/usr/bin/ld: cannot find -llibopencv_ts
/usr/bin/ld: cannot find -llibopencv_video
/usr/bin/ld: cannot find -llibopencv_videostab
collect2: error: ld returned 1 exit status
make: *** [Test_OpenCV01] Error 1

我能够在我的步骤和教程之间找到的唯一区别是:当我运行命令时:

pkg-config --libs opencv

这是我的输出

/usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so /usr/local/lib/libopencv_ts.so /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so 

所以库名称有点不同,所以我使用我拥有的名称。

从eclipse自动执行的命令行是

g++ -L/usr/local/lib/ -o "Test_OpenCV01"  ./src/main.o   -llibopencv_calib3d -llibopencv_contrib -llibopencv_core  -llibopencv_features2d  -llibopencv_flann -llibopencv_gpu -llibopencv_highgui -llibopencv_imgproc -llibopencv_legacy -llibopencv_ml -llibopencv_nonfree -llibopencv_objdetect -llibopencv_photo -llibopencv_stitching -llibopencv_superres -llibopencv_ts -llibopencv_video -llibopencv_videostab

它清楚地指定库路径是 /usr/local/lib/ 这是共享库所在的位置,但是在错误中它说它在 /usr/bin/ld 中找不到 lib 文件

ps我都试过了

1)配置OpenCV以使用共享库:

须藤gedit /etc/ld.so.conf.d/opencv.conf

并在文件末尾添加以下行

/usr/local/lib 保存后正在运行的 sudo ldconfig。

2)运行命令

导出 LD_LIBRARY_PATH=/usr/local/lib

我还添加了

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig 导出 PKG_CONFIG_PATH

到 /etc/bash.bashrc 文件的末尾。

感谢您在高级方面的帮助。

4

2 回答 2

1

您的链接步骤错误地指定了库。如果图书馆是libfoo.so,那么你需要说-lfoo

代替

g++ -L/usr/local/lib/ -o "Test_OpenCV01"  ./src/main.o   -llibopencv_calib3d -llibopencv_contrib -llibopencv_core  -llibopencv_features2d  -llibopencv_flann -llibopencv_gpu -llibopencv_highgui -llibopencv_imgproc -llibopencv_legacy -llibopencv_ml -llibopencv_nonfree -llibopencv_objdetect -llibopencv_photo -llibopencv_stitching -llibopencv_superres -llibopencv_ts -llibopencv_video -llibopencv_videostab

g++ -L/usr/local/lib/ -o "Test_OpenCV01"  ./src/main.o   -lopencv_calib3d -lopencv_contrib -lopencv_core  -lopencv_features2d  -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab

您可以在此处阅读有关链接选项的更多信息。

于 2013-06-25T14:51:09.200 回答
0

尽管文件名类似于 /usr/local/lib 文件夹下的 liblibopencv_core.so ,但在 GCC C++ 链接器库中只需提及opencv_core。对您添加到库中的其他文件执行相同操作。

于 2014-09-23T00:28:55.003 回答