qt这个东西上手快,但是依赖库的设置挺费劲。
这里以opencv为例,介绍qt的依赖设置。opencv的下载方式:
https://blog.csdn.net/weixin_44684139/article/details/104837210
主要更改的是.pro文件:
PATH部分包含INCLUDEPATH和DEPENDPATH,比如:
INCLUDEPATH +=/usr/local/opencv3/include
DEPENDPATH +=/usr/local/opencv3/lib
INCLUDEPATH设定路径后,在工程中include进来的.h文件就可以在指定路径下被找到。
DEPENDPATH设定路径后,共享库即可被寻找到。
共享库部分使用LIBS+=
LIBS += /usr/local/opencv3/lib/libopencv_calib3d.so\
/usr/local/opencv3/lib/libopencv_calib3d.so.3.2\
/usr/local/opencv3/lib/libopencv_calib3d.so.3.2.0\
/usr/local/opencv3/lib/libopencv_core.so\
/usr/local/opencv3/lib/libopencv_core.so.3.2\
/usr/local/opencv3/lib/libopencv_core.so.3.2.0\
/usr/local/opencv3/lib/libopencv_features2d.so\
/usr/local/opencv3/lib/libopencv_features2d.so.3.2\
/usr/local/opencv3/lib/libopencv_features2d.so.3.2.0\
/usr/local/opencv3/lib/libopencv_flann.so\
/usr/local/opencv3/lib/libopencv_flann.so.3.2\
/usr/local/opencv3/lib/libopencv_flann.so.3.2.0\
/usr/local/opencv3/lib/libopencv_highgui.so\
/usr/local/opencv3/lib/libopencv_highgui.so.3.2\
/usr/local/opencv3/lib/libopencv_highgui.so.3.2.0\
/usr/local/opencv3/lib/libopencv_imgcodecs.so\
/usr/local/opencv3/lib/libopencv_imgcodecs.so.3.2\
/usr/local/opencv3/lib/libopencv_imgcodecs.so.3.2.0\
/usr/local/opencv3/lib/libopencv_imgproc.so\
/usr/local/opencv3/lib/libopencv_imgproc.so.3.2\
/usr/local/opencv3/lib/libopencv_imgproc.so.3.2.0\
/usr/local/opencv3/lib/libopencv_ml.so\
/usr/local/opencv3/lib/libopencv_ml.so.3.2\
/usr/local/opencv3/lib/libopencv_ml.so.3.2.0\
/usr/local/opencv3/lib/libopencv_objdetect.so\
/usr/local/opencv3/lib/libopencv_objdetect.so.3.2\
/usr/local/opencv3/lib/libopencv_objdetect.so.3.2.0\
/usr/local/opencv3/lib/libopencv_photo.so\
/usr/local/opencv3/lib/libopencv_photo.so.3.2\
/usr/local/opencv3/lib/libopencv_photo.so.3.2.0\
/usr/local/opencv3/lib/libopencv_shape.so\
/usr/local/opencv3/lib/libopencv_shape.so.3.2\
/usr/local/opencv3/lib/libopencv_shape.so.3.2.0\
/usr/local/opencv3/lib/libopencv_stitching.so\
/usr/local/opencv3/lib/libopencv_stitching.so.3.2\
/usr/local/opencv3/lib/libopencv_stitching.so.3.2.0\
/usr/local/opencv3/lib/libopencv_superres.so\
/usr/local/opencv3/lib/libopencv_superres.so.3.2\
/usr/local/opencv3/lib/libopencv_superres.so.3.2.0\
/usr/local/opencv3/lib/libopencv_videoio.so\
/usr/local/opencv3/lib/libopencv_videoio.so.3.2\
/usr/local/opencv3/lib/libopencv_videoio.so.3.2.0\
/usr/local/opencv3/lib/libopencv_video.so\
/usr/local/opencv3/lib/libopencv_video.so.3.2\
/usr/local/opencv3/lib/libopencv_video.so.3.2.0\
/usr/local/opencv3/lib/libopencv_videostab.so\
/usr/local/opencv3/lib/libopencv_videostab.so.3.2\
/usr/local/opencv3/lib/libopencv_videostab.so.3.2.0\
/usr/local/opencv3/lib/libopencv_viz.so\
/usr/local/opencv3/lib/libopencv_viz.so.3.2\
/usr/local/opencv3/lib/libopencv_viz.so.3.2.0\
可以使用ls命令列出所有全路径,方便加入:
~$ cd /usr/local/opencv3/lib/
lib$ ls -1 |awk '{print i$0}' i=`pwd`'/'
/usr/local/opencv3/lib/libopencv_calib3d.so
/usr/local/opencv3/lib/libopencv_calib3d.so.3.2
/usr/local/opencv3/lib/libopencv_calib3d.so.3.2.0
/usr/local/opencv3/lib/libopencv_core.so
/usr/local/opencv3/lib/libopencv_core.so.3.2
/usr/local/opencv3/lib/libopencv_core.so.3.2.0
/usr/local/opencv3/lib/libopencv_features2d.so
/usr/local/opencv3/lib/libopencv_features2d.so.3.2
/usr/local/opencv3/lib/libopencv_features2d.so.3.2.0
/usr/local/opencv3/lib/libopencv_flann.so
/usr/local/opencv3/lib/libopencv_flann.so.3.2
/usr/local/opencv3/lib/libopencv_flann.so.3.2.0
/usr/local/opencv3/lib/libopencv_highgui.so
/usr/local/opencv3/lib/libopencv_highgui.so.3.2
/usr/local/opencv3/lib/libopencv_highgui.so.3.2.0
/usr/local/opencv3/lib/libopencv_imgcodecs.so
/usr/local/opencv3/lib/libopencv_imgcodecs.so.3.2
/usr/local/opencv3/lib/libopencv_imgcodecs.so.3.2.0
/usr/local/opencv3/lib/libopencv_imgproc.so
/usr/local/opencv3/lib/libopencv_imgproc.so.3.2
/usr/local/opencv3/lib/libopencv_imgproc.so.3.2.0
/usr/local/opencv3/lib/libopencv_ml.so
/usr/local/opencv3/lib/libopencv_ml.so.3.2
/usr/local/opencv3/lib/libopencv_ml.so.3.2.0
/usr/local/opencv3/lib/libopencv_objdetect.so
/usr/local/opencv3/lib/libopencv_objdetect.so.3.2
/usr/local/opencv3/lib/libopencv_objdetect.so.3.2.0
/usr/local/opencv3/lib/libopencv_photo.so
/usr/local/opencv3/lib/libopencv_photo.so.3.2
/usr/local/opencv3/lib/libopencv_photo.so.3.2.0
/usr/local/opencv3/lib/libopencv_shape.so
/usr/local/opencv3/lib/libopencv_shape.so.3.2
/usr/local/opencv3/lib/libopencv_shape.so.3.2.0
/usr/local/opencv3/lib/libopencv_stitching.so
/usr/local/opencv3/lib/libopencv_stitching.so.3.2
/usr/local/opencv3/lib/libopencv_stitching.so.3.2.0
/usr/local/opencv3/lib/libopencv_superres.so
/usr/local/opencv3/lib/libopencv_superres.so.3.2
/usr/local/opencv3/lib/libopencv_superres.so.3.2.0
/usr/local/opencv3/lib/libopencv_videoio.so
/usr/local/opencv3/lib/libopencv_videoio.so.3.2
/usr/local/opencv3/lib/libopencv_videoio.so.3.2.0
/usr/local/opencv3/lib/libopencv_video.so
/usr/local/opencv3/lib/libopencv_video.so.3.2
/usr/local/opencv3/lib/libopencv_video.so.3.2.0
/usr/local/opencv3/lib/libopencv_videostab.so
/usr/local/opencv3/lib/libopencv_videostab.so.3.2
/usr/local/opencv3/lib/libopencv_videostab.so.3.2.0
/usr/local/opencv3/lib/libopencv_viz.so
/usr/local/opencv3/lib/libopencv_viz.so.3.2
/usr/local/opencv3/lib/libopencv_viz.so.3.2.0
/usr/local/opencv3/lib/pkgconfig
/usr/local/opencv3/lib/python2.7
如果依赖库或者路径设置不完全,一定会报一个迷茫的错误:
error: collect2: error: ld returned 1 exit status