Linking libraries to a QT project using pkg-config output

只愿长相守 提交于 2019-11-28 08:09:50
CONFIG += link_pkgconfig
PKGCONFIG += opencv

(I got this answer from http://beaufour.dk/blog/2008/02/using-pkgconfig.html)

Salida Software

Ken's answer worked great. I just had to remove the spaces on either side of the += first.

CONFIG+=link_pkgconfig PKGCONFIG+=opencv

Something like this in your qmake file should do

LIBS += `pkg-config --libs opencv`

Edit: Hmm, Ken Bloom's answer might be more portable, but erhm not documented?

In the newer version of Qt, this needs to be done to avoid a package not found error:

QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig
PKGCONFIG += protobuf #or whatever package here

Also had to do this for Mac:

mac {
  PKG_CONFIG = /usr/local/bin/pkg-config
}

Add the following lines to your .pro file:

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