本文介紹了使用 pkg-config 輸出將庫鏈接到 QT 項(xiàng)目的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
這是一個新手問題.我正在嘗試將 OpenCV 庫添加到 QT 項(xiàng)目中.
This is a bit of a newbie question. I am trying to add the OpenCV libraries to a QT project.
這個問題表示鏈接標(biāo)志由
pkg-config --libs opencv
如果我將命令行輸出粘貼到項(xiàng)目文件中,例如:
If I paste the command line output into the project file like:
LIBS += -L/usr/local/lib -lml -lcvaux -lhighgui -lcv -lcxcore
然后一切都可以正常編譯,但現(xiàn)在這不是可移植的.如何簡單地引用命令的輸出?
then everything compiles fine, but now this isn't portable. How can I simply reference the output of the command?
更新:嘗試了 Ken Bloom 的建議,但無法編譯.實(shí)際生成的編譯器命令是
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)
這篇關(guān)于使用 pkg-config 輸出將庫鏈接到 QT 項(xiàng)目的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!