Linking OpenCV to Qt Creator

不羁的心 提交于 2021-02-17 03:27:27

问题


I'm trying to use opencv 4 in QT creator, I'm working on Mac but I can't be able to link the library, I always have a error like on picture 2.

please help me, I'm really hopeless.


回答1:


First of all be sure you installed OpenCV correctly and working fine. You can check OpenCV exist or not by:

pkg-config --modversion opencv

It depends how you installed OpenCV but linking OpenCV libraries and flags to Qt is simply like adding these two line to your .pro file:

INCLUDEPATH += /usr/local/include/opencv # depends on how you installed
LIBS += `pkg-config --cflags --libs opencv`

This tutorial is also very helpful.




回答2:


So, I have a solution here, I have install the OpenCV 4. In

/usr/local/Cellar/opencv/4.2.0_1/lib/pkgconfig

I have a opencv4.pc not opencv.pc and the "opencv development package not found" error came from here.

Edit your .pro file with

QT_CONFIG -= no-pkg-config
CONFIG  += link_pkgconfig
PKGCONFIG += opencv4 

note that it's opencv4.

after you have to configure the Build Environment in Qt Creator normally.



来源:https://stackoverflow.com/questions/60160885/linking-opencv-to-qt-creator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!