使用 qmake/Qt Creator 与调试/发布库链接 [英] Linking with a debug/release lib with qmake/Qt Creator

查看:57
本文介绍了使用 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 与调试/发布库链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆