使用pkg-config输出将库链接到QT项目 [英] Linking libraries to a QT project using pkg-config output
本文介绍了使用pkg-config输出将库链接到QT项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个新手问题。我试图将OpenCV库添加到QT项目中。
This is a bit of a newbie question. I am trying to add the OpenCV libraries to a QT project.
此问题表示链接标志由
pkg-config --libs opencv
如果我将命令行输出粘贴到项目文件中, p>
If I paste the command line output into the project file like:
LIBS += -L/usr/local/lib -lml -lcvaux -lhighgui -lcv -lcxcore
然后一切编译正常,但现在这是不可移植的。我如何简单地引用命令的输出?
then everything compiles fine, but now this isn't portable. How can I simply reference the output of the command?
更新:试图肯布鲁克的建议,但它不会编译。实际生成的编译器命令是
Update: Tried Ken Bloom's suggestion, but it won't compile. The actual generated compiler commands are
# How it should be, at least on my machine
g++ -o QOpenCVTest main.o qopencvtest.o moc_qopencvtest.o -L/usr/lib -L/usr/local/lib -lml -lcvaux -lhighgui -lcv -lcxcore -lQtGui -lQtCore -lpthread
# with CONFIG and PKGCONFIG
g++ -o QOpenCVTest main.o qopencvtest.o moc_qopencvtest.o -L/usr/lib -lQtGui -lQtCore -lpthread
推荐答案
CONFIG += link_pkgconfig
PKGCONFIG += opencv
(我从 http://beaufour.dk/blog/2008/02/using-pkgconfig.html )
这篇关于使用pkg-config输出将库链接到QT项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文