当我将其写入终端时:
g++ LATCH_match.cpp -std=c++11 $(pkg-config opencv --cflags --libs)
我遇到了这样的错误:
/usr/bin/ld: cannot find -lippicv
collect2: error: ld returned 1 exit status
我尝试了很多方法但还是找不到解决方案。
答案1
如果您已验证安装是在编译后进行的,则可以更新 opencv 的 pkgconfig(/usr/local/lib/pkgconfig/opencv.pc)
以包含第三方。使用以下指南进行更新
# Package Information for pkg-config
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
libdir3rd=${exec_prefix}/share/OpenCV/3rdparty/lib
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include
Name: OpenCV
Description: Open Source Computer Vision Library
Version: 3.1.0
Libs: -L${libdir} -L${libdir3rd} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lippicv -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core -lopencv_ts
Libs.private: -L/usr/lib/x86_64-linux-gnu -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Test -lQt5Concurrent -lQt5OpenGL -lwebp -lpng -lz -ltiff -ljasper -ljpeg -lImath -lIlmImf -lIex -lHalf -lIlmThread -lgstvideo-1.0 -lgstapp-1.0 -lgstbase-1.0 -lgstriff-1.0 -lgstpbutils-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -ldc1394 -lv4l1 -lv4l2 -lavcodec -lavformat -lavutil -lswscale -lavresample -lgphoto2 -lgphoto2_port -lexif -ldl -lm -lpthread -lrt -lGLU -lGL -ltbb -latomic
Cflags: -I${includedir_old} -I${includedir_new}
答案2
好的,我遇到了完全相同的问题。我确实用重新编译了-DWITH_IPP=ON
,并且没有构建错误或安装错误。看起来安装程序将 libippicv 放在了以下路径:
/usr/local/share/OpenCV/3rdparty/lib/libippicv.a
但安装的文件/usr/local/lib/pkgconfig/opencv.pc
只是引用-lippicv
,没有提供正确的路径。所以我认为有些地方出了问题。
答案3
您只需在 /lib 目录中添加一个符号链接即可解决此问题:
cd /lib
sudo ln -s /usr/local/share/OpenCV/3rdparty/lib/libippicv.a libippicv.a
(假设你的图书馆在/usr/local/share/OpenCV/3rdparty/lib
)