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

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

问题描述

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

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

但是我看不到如何使用其他 -L 用于发布和调试版本的命令。

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

qmake是否支持执行此操作?

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
}

如果将DEBUG添加到CONFIG qmake变量中,则使用调试括号内的位,类似如果已将RELEASE添加到CONFIG变量中,则包含发行版括号。

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.

您还可以使用!debug而不是 release(即,当debug不是在配置中)

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

您可以找到更多信息关于qmake的信息此处

You can find more information on qmake here.

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

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