在QtCreator Linux中链接OpenCV库

时间:2017-07-13 10:20:43

标签: c++ linux opencv qt-creator linker-errors

我已经从arch-repositories安装了OpenCV,但已将其删除。现在我从源like descriped here安装了OpenCV。我有问题以这种方式链接Qt-Creator.pro文件中的库:

`pkg-config opencv --cflags --libs`

在旧的存储库安装中,这已经有效了。

如果我手动给它一个像下面这样的路径一切正常:

LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui

我已在〜/ .bashrc

中添加了行export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

如果我输入我要在终端中使用的行,我会得到以下输出:

-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_photo -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_ml -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann -lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto -lopencv_imgproc -lopencv_core

编辑:还有一个包含以下行的文件/etc/local/lib/pkgconfig/opencv.pc:

 Package Information for pkg-config

prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 3.3.0
Libs: -L${exec_prefix}/lib -lopencv_stitching -lopencv_superres -lopencv_videos$
Libs.private: -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-go$
Cflags: -I${includedir_old} -I${includedir_new}

我希望有人可以帮助我,这样我就可以再次使用连接库的简短方法。

0 个答案:

没有答案