将外部库添加到 Qt Creator 项目中

2022-11-21C/C++开发问题
6

QtMQ=="> 本文介绍了将外部库添加到 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 项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End
Qt

相关推荐

如何在 Qt 中实现 OpenSSL?
How to implement OpenSSL in Qt?(如何在 Qt 中实现 OpenSSL?)...
2024-08-14 C/C++开发问题
6

如何使用 MinGW 编译器和 SSL 支持静态编译 Qt
how to statically compile Qt using MinGW compiler and SSL support(如何使用 MinGW 编译器和 SSL 支持静态编译 Qt)...
2024-08-14 C/C++开发问题
6

Qt设置QLineEdit的背景颜色
Qt Set Background Color of QLineEdit(Qt设置QLineEdit的背景颜色)...
2024-08-13 C/C++开发问题
5

在 raspberry 中交叉编译的 qt 中构建应用程序时出错
Error while building app in cross-compiled qt in raspberry(在 raspberry 中交叉编译的 qt 中构建应用程序时出错)...
2023-12-03 C/C++开发问题
6

Qt Creator、ptrace:不允许操作.什么是永久解决方案?
Qt Creator, ptrace: Operation not permitted. What is the permanent solution?(Qt Creator、ptrace:不允许操作.什么是永久解决方案?)...
2023-12-03 C/C++开发问题
8

查找从未调用的函数
Find never-called functions(查找从未调用的函数)...
2023-12-03 C/C++开发问题
3