使用VC++编译器静态编译Qt5.5

转载自:http://amin-ahmadi.com/2015/07/03/how-to-build-qt-5-5-static-libraries-using-any-microsoft-visual-c-compiler/

亲测,编译成功,能正常使用。

Following steps will help you with building Qt 5.5 Static Libraries with any MSVC Compiler. I have used MSVC2010 in this example but it should be the same for any compiler version from 2005 to 2015 (Visual Studio 2005 (8.0), VC++ 14.0)

Note that building Qt like this will remove all dependencies meaning there won’t be any need for MSVC dlls)

1. Download and extract qt source to this path:
C:\Qt\5.5\qt-everywhere-opensource-src-5.5.0

2. Change Environment variables like this:
PATH = C:\Qt\Tools\QtCreator\bin

3. Create folder C:\Qt\5.5\msvc2010_static (if you are not building using msvc2010 then create a folder according to the compiler you are using, like msvc2013 or msvc2008 etc.)

4. goto C:\Qt\5.5\qt-everywhere-opensource-src-5.5.0\qtbase\mkspecs\common
and change msvc-desktop.conf like this (change all MD to MT to remove dependency on msvc dlls)

initial values:
QMAKE_CFLAGS_RELEASE = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MDd

should be changed to:
QMAKE_CFLAGS_RELEASE = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MTd

5. Using MSVC2010 Command Line tools, running as admin, Configure using following command: (first change directory to here using “cd” command : C:\Qt\5.5\qt-everywhere-opensource-src-5.5.0)
(No need to remind that you need to use the Command Line Tools for your own compiler, like MSVC2013 or 2005 or 2008, if you are not using MSVC2010)

configure.bat -static -debug-and-release -prefix "C:\Qt\5.5\msvc2010_static" -platform win32-msvc2010 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -qt-sql-odbc -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests

(Notice that the parameter -platform win32-msvc2010 should be set according to the compiler you are using)
(Also note that you can add or remove parts and pieces of the libraries you are building by adding or removing parameters above, for example I always use ODBC so I add -qt-sql-odbc parameter but you might want to remove it if you don’t need it.)

6. Run jom (without any parameters so that the ideal thread count is calculated automatically)

7. run jom install

Ask me if there are any questions regarding the steps, I agree some of them might be a little bit vague to beginners, but I’m ready to help.

Please do not forget that to use Static libraries commercially you need to obtain a proper license from Qt and everything described here is just for educational purposes.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值