利用vs2010编译64位Qt4.8.6(附打包说明)

1、下载Qt4.8.6的源码:http://download.qt.io/archive/qt/

2、打开vs2010的命令提示行,进入到源码路径(我本地E:\\opensource\\Qt4.8.6-x64-msvc2010),然后输入:

【configure -debug-and-release -opensource -platform win32-msvc2010】对所有qt组件都进行configure。

【configure -opensource -nomake demos -nomake examples -platform win32-msvc2010 -webkit】对指定组件进行configure。

3、上一步执行完毕后,键入nmake,完成即可;或者直接打开project.sln进行编译(这种编译慢,但是出现问题好解决些)。注意在执行第二步时会要求键入y(同意一些开源协议Do you accept the terms of the license?)。

注意:在使用project.sln编译webkit模块发生了错误,通过该链接可以找到解决方法:https://blog.csdn.net/luofeixiongsix/article/details/79709459,不再赘述。

4、需要说明的是,编译好的版本不能够拷贝到其他电脑上正常使用,是因为QT_INSTALL_PREFIX等宏定义是编译时的源码路径,

在qt4中可以使用qt.conf对QT_INSTALL_PREFIX等宏定义进行重新指定路径。

qt.conf的存放路径:和qmake同一级即可。

内容:

[Paths]                      
Prefix = C:/Qt/Qt4.8.6-x64-msvc2010/  ;自定义的qt路径            
Translations = translations  
Examples = examples          
Demos = demos     

5、当然编译完成后最好打包成可安装的包最好,我之前使用inno setup进行打包,附上打包的脚本:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{3CBF4FA6-BD79-49F8-96F4-6BB555651A82}
AppName=Qt4.8.6-x64-msvc2010
AppVersion=4.8.6
;AppVerName=Qt4.8.6-x64-msvc2010 4.8.6
DefaultDirName={pf}\Qt4.8.6-x64-msvc2010
DefaultGroupName=Qt4.8.6-x64-msvc2010
DisableProgramGroupPage=yes
OutputDir=E:\opensource
OutputBaseFilename=Qt4.8.6-x64-msvc2010
SetupIconFile=E:\opensource\qt-logo.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "E:\opensource\Qt4.8.6-x64-msvc2010\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

;[INI]
;Filename: "{app}/bin/qt.conf"; Section: "Paths"; Key: "Prefix"; String: "{app}"
;Filename: "{app}/bin/qt.conf"; Section: "Paths"; Key: "Translations"; String: "translations"
;Filename: "{app}/bin/qt.conf"; Section: "Paths"; Key: "Plugins"; String: "plugins"
;Filename: "{app}/bin/qt.conf"; Section: "Paths"; Key: "Imports"; String: "imports"
;Filename: "{app}/bin/qt.conf"; Section: "Paths"; Key: "Examples"; String: "examples"
;Filename: "{app}/bin/qt.conf"; Section: "Paths"; Key: "Demos"; String: "demos" 
;打算这样建立qt.conf文件,发现{app}中的'\'在windows系统中涉及到转义故使用下面run中的批处理进行建立。

[run]
Filename: "{app}\UpdateQt.bat";  ;根据qt的被安装路径建立qt.conf.    



UpdateQt.bat存放于qmake的上一级路径,即和bin同目录,内容如下:

::
:: this file should be placed in Qt root directory
:: eg. if qmake.exe is in C:\Qt\bin, 
::     this script should be in C:\Qt
::
:: Reference:http://www.cuteqt.com/blog/?p=149
:: Reference:http://blog.csdn.net/jq0123/article/details/4325256

REM get current directory
REM and replace \ with /
SET PWD=%~dp0
SET CONF=%PWD%\bin\qt.conf
SET PWD=%PWD:\=/%


echo [Paths]                      >%CONF%
echo Prefix = %PWD%               >>%CONF%
echo Translations = translations  >>%CONF%
echo Examples = examples          >>%CONF%
echo Demos = demos                >>%CONF%

 

你可能感兴趣的:(利用vs2010编译64位Qt4.8.6(附打包说明))