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
如果我将命令行输出粘贴到项目文件中,例如:
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 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 pkg-config 输出将库链接到 QT 项目


基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 这个宏可以转换成函数吗? 2022-01-01