如何用VS2010编译Qt5.3.2

2025-11-09 04:11:14

1、当然是需要一个C++编译器,我使用用Visual C++ 2010, 也可以用MinGW。

如何用VS2010编译Qt5.3.2

2、在Windows上编译Qt需要一些库,参见http://doc.qt.io/qt-5/windows-requirements.html。

如何用VS2010编译Qt5.3.2

3、需要以下3个编译时要用的工具(运行时不需要):

ActivePerl - Install a recent version of ActivePerl (download page) and add the installation location to your PATH.

Python - Install Python from the here and add the installation location to your PATH in order to be able to build Qt WebKit.

Install Ruby from here and add the installation location to your PATH in order to be able to build Qt WebKit.

把这3个下载安装上即可。

4、把下载下来的Qt源码解压至目录需要的目录,然后在此目录根下创建一个批处理文件,将下面代码复制到文件并保存:

@echo off

ECHO 设置 Visual Studio environment...

CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64

title Command Prompt (MSVC++ 2010) x64

SET QTSRC_DIR=H:\qt-msvc2010-x64

SET QMAKESPEC=win32-msvc2010

SET PATH=%PATH%;%QTSRC_DIR%\qtbase\bin;%QTSRC_DIR%\gnuwin32\bin

SET PATH=%PATH%;C:\Python27;C:\Perl64\bin;C:\Ruby21-x64\bin;

ECHO 按任意键,进行configure...

@PAUSE>NUL

CALL configure -opensource -mp -debug-and-release -nomake examples -no-opengl -no-angle -skip qtquick1 -skip qtquickcontrols -skip qtsensors -skip qtwebkit

ECHO 按任意键,开始编译...

@PAUSE>NUL

CALL jom.exe -j 4

REM 重新配置和编译请使用

REM nmake distclean 或jom clean

goto :eof

如何用VS2010编译Qt5.3.2

5、上面的代码设置好了VC++环境变量、源码目录、必备工具执行目录等等;

通过configure设置了需要编译的模块和不需要编译的模块。通过禁止不需要的编译模块,可以大幅加快编译速度;

jom.exe -j 4指定使用4个线程并行编译。

6、写好保存为bat文件,在命令行执行即可。

如何用VS2010编译Qt5.3.2

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢