本文介紹了使用 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
如果我將命令行輸出粘貼到項目文件中,例如:
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?
更新:嘗試了 Ken Bloom 的建議,但無法編譯.實際生成的編譯器命令是
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 項目的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!