Adding external library into Qt Creator project(将外部库添加到 Qt Creator 项目中)
问题描述
如何将外部库添加到由 Qt Creator RC1(版本 0.9.2)构建的项目中?例如win32函数EnumProcesses()
需要在项目中加入Psapi.lib
才能构建.
How can I add external library into a project built by Qt Creator RC1 (version 0.9.2)? For example, the win32 function EnumProcesses()
requires Psapi.lib
to be added in the project to build.
推荐答案
正确的做法是这样的:
LIBS += -L/path/to -lpsapi
这样它就可以在 Qt 支持的所有平台上运行.这个想法是您必须将目录与库名称分开(没有扩展名和任何lib"前缀).当然,如果您包含特定于 Windows 的库,这真的无关紧要.
This way it will work on all platforms supported by Qt. The idea is that you have to separate the directory from the library name (without the extension and without any 'lib' prefix). Of course, if you are including a Windows specific lib, this really doesn't matter.
如果您想将 lib 文件存储在项目目录中,您可以使用 $$_PRO_FILE_PWD_
变量引用它们,例如:
In case you want to store your lib files in the project directory, you can reference them with the $$_PRO_FILE_PWD_
variable, e.g.:
LIBS += -L"$$_PRO_FILE_PWD_/3rdparty/libs/" -lpsapi
这篇关于将外部库添加到 Qt Creator 项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将外部库添加到 Qt Creator 项目中


基础教程推荐
- 设计字符串本地化的最佳方法 2022-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- C++,'if' 表达式中的变量声明 2021-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01