2024年,使用C++从0开始编译QT源码
背景:
由于工作需要,必须使用VS2010(对应编译链MSVC100);
由于工作需要,必须进行64的编译;
QT官网把大陆的IP地址给封禁了,导致无法下载qt-opensource-windows-x86-msvc2010_opengl-5.4.2.exe(即使科学了,但是非常蛋疼的是官网只提供了x86 32位的动态库)
虽然热心网友提供了64位的qt-5.5.0-x64-mingw510r0-seh-rev0.exe,但是编译链是mingw不是MSVC100。跟现有的技术代码不能很好的兼容;
综上所述,必须要学会自己编译QT的源码; (MSVC100+64BIT)
1、编译QT源码;
Visual C++ 2010 contains all necessary SDKs for Qt compilation. However if you plan to use Qt with Phonon you need to install DirectX SDK first.
Install Perl if you are going to compile Qt >= 4.8.0
https://strawberryperl.com/
ActivePerl 他们家的东西,下载不到,因为无法访问亚马逊服务器。
Download and extract Qt 4.7.1 Source Code. (Qt 4.8.0 or Latest snapshot).
https://download.qt.io/new_archive/qt/5.4/5.4.0/single/qt-everywhere-opensource-src-5.4.0.zip
Copy contents of the folder
qt-everywhere-opensource-src-4.7.1
to the directory where you intend to install Qt. In our case this isC:\Qt\4.7.1
.Set up environmental variables
QTDIR=C:\Qt\4.7.1QMAKESPEC=win32-msvc2010
Update
PATH
variable to include%QTDIR%\bin
Download the latest version of jom.
Extract jom files to
C:\Qt\jom
folderStart Visual Studio 2010 Command Prompt:
Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt
.Run following commands in it (every line is a different command: type it then press Enter
cd c:\Qt\4.7.1
configure -debug-and-release -opensource -platform win32-msvc2010
..\jom\jom.exe -j N
Where N
is number of CPU cores you want to utilize for Qt compilation. Larger is better.
Download and install Qt Visual Studio Add-in.
Run Visual Studio 2010. Integrate just compiled Qt to IDE using menu
Qt > Qt Options > Qt Versions > Add
参考:
尝试了很长时间,还是失败,太难了。
Perl版本不对?