使用 qmake/Qt Creator 与调试/发布库链接

2023-01-22C/C++开发问题
11

本文介绍了使用 qmake/Qt Creator 与调试/发布库链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 Qt Creator 并且有一个依赖于 C++ 静态库项目的 Qt GUI 项目.我想将 GUI 应用程序的发布版本与 .lib 的发布版本和 GUI 应用程序的调试版本与调试 .lib 链接起来.通过在我的 .pro 文件中包含如下一行,我找到了如何向项目添加其他库的方法:

LIBS += -L./libfolder -lmylib.lib

但我不知道如何使用不同的 -L 命令进行发布和调试版本.

qmake 是否支持这样做?

解决方案

在你的项目文件中你可以做这样的事情

调试{LIBS += -L./libfolder -lmydebuglib.lib}释放 {LIBS += -L./libfolder -lmyreleaselib.lib}

如果 DEBUG 已添加到 CONFIG qmake 变量中,则使用调试括号内的位,如果 RELEASE 已添加到 CONFIG 变量中,则释放括号内的内容也将包含在内.

您也可以使用!debug"而不是release"(即当调试不在配置中时)

您可以在此处找到有关 qmake 的更多信息.>

I am using Qt Creator and have a Qt GUI project that depends on a C++ static library project. I want to link the release version of the GUI app with the release build of the .lib and the debug release of the GUI app with the debug .lib. I have found out how to add additional libraries to the project by including a line like the following in my .pro file:

LIBS += -L./libfolder -lmylib.lib

But I cannot see how I can use a different -L command for release and debug builds.

Is there support in qmake to do this?

解决方案

In your project file you can do something like this

debug {
    LIBS += -L./libfolder -lmydebuglib.lib
}

release {
    LIBS += -L./libfolder -lmyreleaselib.lib
}

The bit inside the debug braces is used if DEBUG has been added to the CONFIG qmake variable, similarly stuff inside the release brackets is included if RELEASE has been added to the CONFIG variable.

You can also use "!debug" rather than "release" (i.e. when debug isn't in the config)

You can find more information on qmake here.

这篇关于使用 qmake/Qt Creator 与调试/发布库链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6