标题:说说我自己编译Qt5.0.0的过程(Windows)
作者:roywillow
日期:2012-12-21 23:59
内容:
貌似很多人编译Qt5.0.0碰壁了呢,我说说我自己的编译过程吧。
首先credits一下某jerry童鞋,是他发现了我编译不通的时候的症结所在。
工具和环境准备:
编译器——MinGW-w64(x86_64-w64-mingw32-gcc-4.7.2-release-win64_rubenvb,是个w64的personal build)
Perl
Python
嗯,我没用什么msys
也没有准备SSL和ICU(webkit就再见了)
解压好源码
找个地方创建个叫QtBuild之类的文件夹,作为编译的时候的工作目录(我比较喜欢在源码外编译,这样感觉更干净一些,也方便清理)
cmd下,临时设置一下环境变量,比如我的:
set PATH=E:\Perl64\bin;E:\Python33;E:\GCC-4.7-MinGW\mingw64\bin;%PATH%
cd到QtBuild目录,执行【blablabla】\qt-everywhere-opensource-src-5.0.0\configure,估计会碰到什么qtbase\\configure.exe不是内部或外部命令之类的错误。然后找找qtbase目录下果断没有configure.exe。也就是说Qt发布的时候根本就没提供编译好的这东西……
逆流而上查原因,源码根目录下configure.bat通过perl调用旁边的configure,这个configure又调用qtbase里的configure.bat,然后这个东西,就在第45行:
if not exist %QTSRC%\.gitignore goto sconf
和第109行
:sconf
%QTSRC%\configure.exe %*
也就是说,如果没找到.gitignore这个文件夹,那么就认为你已经有了configure.exe,直接调用之;然而对于我们来说,configure.exe也不存在。
这是不是默认用户是从git上得到的源码啊,并且还认为Qt发布后打包的源码应该已经准备好了configure.exe吧……
之后就比较明了了。某jerry的做法是把这一行注释掉。我的做法就有些麻烦。
手动在qtbase里创建.gitignore文件夹(cmd下,资源管理器不承认这个文件名),然后在QtBuild目录下调用qt-everywhere-opensource-src-5.0.0\configure -help(我不希望直接就这么开始编译了,想先看看参数),然后就在QtBuild\qtbase里找到了生成的configure.exe。
将编译好的configure.exe复制到qt-everywhere-opensource-src-5.0.0\qtbase中,删掉刚才创建的.gitignore文件夹。于是,这么一来我们的源码就比较类似于Qt4.x发布的打包好的源码了。
参考刚才输出的-help信息,确定好自己需要的参数,然后直接调用源码根目录下的configure.bat就可以了。
以下是我的参数
..\qt-everywhere-opensource-src-5.0.0\configure.bat -release -opensource -fast -prefix "E:/Qt5 ..
#1 [roywillow 12-22 00:14]
就在刚才我又发现了更根本一些的症结所在
http://qt-project.org/forums/viewthread/22932/
第2个回复的edit
我用的是tar.gz源码包,因为体积小,而其实zip才是为windows准备的……
#2 [ugame 12-22 04:27]
vs怎么编译?
#3 [呆呆很呆 12-22 09:12]
都喜欢用那么长的参数啊 我一般就用一两个
configure -no-opengl
-no-opengl是因为默认的-opengl 会给出警告 然后编译出错
PS:话说我找了半天没找到-no-webkit 原来已经自动化了 如果安装了ICU就是-webkit 没有就是-no-webkit
#4 回 3楼(呆呆很呆) 的帖子 [roywillow 12-22 09:44]
你连prefix都不用么……
#5 [myseemylife 12-22 10:37]
关于Opengl 的选项
我的机器上没有预装opengl和DXSDK。。。。
zip包下opengl desktop直接就不过了。。
Windows
Windows Graphics Drivers
QML2 requires OpenGL 2.1 or higher or Open GL ES 2.0 to work.
In Windows, two options are available:
1.Use the ANGLE-library to translate OpenGL calls into DirectX (default)
2.Use the native OpenGL driver for your graphics card
A copy of ANGLE is bundled in Qt 5. To use Option 1, you need to install the DirectX SDK (Note: Starting from Windows Kit 8, this is included in the Windows SDK).
To use Option 2, you need to ensure that your graphics card driver supports OpenGL 2.1 or higher (Note: The stock Windows driver only supports OpenGL 1.1, which is insufficient), and pass `-opengl desktop’ to configure.exe.
这是官网wiki的