把静态编译的QT添加到QTCreator当中创建新工程

How to integrate static version of Qt additionally to QtCreator

Open QtCreator and go to the Tools / Options menu. Select Qt4:

Select Options - Qt4 - Add

Add a new version by pressing the plus button enter a name and the path to qmake (Path-To-Qt-SDK\qt_static\bin\qmake.exe) add the MinGW directory (copy from 4.7.0)

Changes in the settings

If you create a new project, you are asked, which Qt version you want to use. Leave both checkboxes checked. Create new project

If you already have a project and want to add this version, go to Projects (left hand of QtCreator) and add a setting.

Change project settings

For the static project configuration, you should add CONFIG+=static in the command line. Open the project settings, and press details for the qmake step. In the additional arguments, add CONFIG+=static

changes qmake step

In the project (*.pro) file, add the following:

static { # everything below takes effect with CONFIG ''= static
 CONFIG+= static
 CONFIG += staticlib # this is needed if you create a static library, not a static executable
 DEFINES+= STATIC
 message("~~~ static build ~~~") # this is for information, that the static build is done
 mac: TARGET = $$join(TARGET,,,_static) #this adds an _static in the end, so you can seperate static build
from non static build
 win32: TARGET = $$join(TARGET,,,s) #this adds an s in the end, so you can seperate static build from
non static build
}

What also makes sense is to add a d to the binary, if you create a debug build:

# change the nama of the binary, if it is build in debug mode
CONFIG (debug, debug|release) {
 mac: TARGET = $$join(TARGET,,,_debug)
 win32: TARGET = $$join(TARGET,,,d)
}

Now you have it. Build the static version (select he static project settings and build it).

changes qmake step

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值