VS2015编译Qt5.9, Qt5.10源码(附依赖链接)

还是写一下想法吧(好久不写东西,将就着看哈)

记得刚毕业的时候,编译了Qt4.8.6的源码,随着时间的推移和工作的变迁,需要再次编译Qt源码,不过版本变成了vs2015+qt5.9.4->+, 前段时间需要在CSDN上下载资源,尴尬的是CSDN没分了,所以就把编译步骤整理了一下,上传了以便能换些分数,由于这段时间工作太忙,也就没太在意,今天偶然看到近两天依然有人在下载编译步骤,也看到有人说文档写的太糙,所以就把编译步骤及一些中间环境贴出来,希望能对有需要的同学有所帮助。

编译之前也看了网上的很多帖子,但是由于时间太久,也没有记住帖子链接,在这儿就不写了,见谅!

先说一下我这边的环境,win10 64位家庭版,vs2015专业版(update3)

****编译需要Win10SDK

注:下面步骤括号中是我这边使用的一些依赖的版本号

1.  官网下载安装ActivePerl并设置环境变量(ActivePerl-5.24.1.2402-MSWin32-x64-401627.exe);

2.  官网下载python并设置环境变量(不要使用python3, 我这边用的是python2.7.13);

3. 官网下载nasm并设置环境变量(nasm-2.14rc0-installer-x64.exe);

4. 官网下载ruby并设置环境变量(rubyinstaller-2.4.1-1-x64.exe);

5. 下载jom并设置环境变量;

6. 下载ninja并设置环境变量;

7. openssl并设置环境变量(并不是所有的openssl版本都好用, 我当时用的是opernssl-1.0.2l,我是下载的源码编译的);

8. icu 并设置环境变量(我当时用的是icu58.1, 可以直接下载编译好的文件,也可以下载源码自己编译,官网上有编译方法);

9. 修改电脑区域位置 --> 美国,语言 --> 英语(美国),时区 --> 太平洋时间(美国和加拿大);

10. 在执行编译脚本之前关闭电脑的防护软件以防止编译过程中产生的中间文件被删除;

11. 打开vs本机工具提示符命令行窗口切换到源码路径下执行下面的脚本;

编译脚本:

#x86
set msvc_path=C:/Program Files (x86)/Microsoft Visual Studio 14.0
set make_spec=win32-msvc
SET CL=/MP
set src_path=E:/qt-src/qt5.9.4_x86
set dst_path=D:/develop/qt5.9.4_x86
set icu_path=E:/qt-src/icu_x86
set openssl_path=E:/qt-src/openssl_x86
set PATH=%src_path%/qtbase/bin;%src_path%/qtbase/lib;%src_path%/gnuwin32/bin;%PATH%
set LIB=%LIB%;%icu_path%/lib;%openssl_path%/lib
set INCLUDE=%INCLUDE%;%icu_path%/include;%openssl_path%/include
set PATH=%PATH%;%icu_path%/bin;%openssl_path%/bin;%icu_path%/lib;%openssl_path%/lib

call "%msvc_path%/VC/vcvars32.bat"

call configure -mp -opensource -confirm-license -platform %make_spec% -debug-and-release -force-debug-info -qt-sqlite -qt-pcre -qt-zlib -qt-libpng -qt-libjpeg -opengl  desktop -qt-freetype  -icu -openssl -nomake tests  -prefix %dst_path%

pause

jom #也可以使用nmake

jom install

nmake docs
#x64
set msvc_path=C:/Program Files (x86)/Microsoft Visual Studio 14.0
set make_spec=win32-msvc
SET CL=/MP
set src_path=E:/qt-src/qt5.9.4_x64
set dst_path=D:/develop/qt5.9.4_x64
set icu_path=E:/qt-src/icu_x64
set openssl_path=E:/qt-src/openssl_x64
set PATH=%src_path%/qtbase/bin;%src_path%/qtbase/lib;%src_path%/gnuwin32/bin;%PATH%
set LIB=%LIB%;%icu_path%/lib;%openssl_path%/lib
set INCLUDE=%INCLUDE%;%icu_path%/include;%openssl_path%/include
set PATH=%PATH%;%icu_path%/bin;%openssl_path%/bin;%icu_path%/lib;%openssl_path%/lib

call "%msvc_path%/VC/vcvarsall.bat" amd64

call configure -mp -opensource -confirm-license -platform %make_spec% -debug-and-release -force-debug-info -qt-sqlite -qt-pcre -qt-zlib -qt-libpng -qt-libjpeg -opengl  desktop -qt-freetype  -icu -openssl -nomake examples -nomake tests  -prefix %dst_path%

pause

jom

jom install

nmake docs

 

编译完成后:

在上面的编译脚本中已经添加了帮助文档的生成命令(nmake docs),编译完成后可以使用下面的python脚本抽取帮助文档

# -*-coding: utf-8 -*-

# > Author:     hewl
# > Email:      
# > DateTime:   2018/2/8 11:06
# > Software:   

import os
import shutil

def extract_qch(opt_dir):
    dir_list = os.listdir(opt_dir)
    for var in dir_list:
        path = os.path.join(opt_dir, var)
        if os.path.isdir(path):
            extract_qch(path)
        elif os.path.isfile(path):
            (file_path, tmp_file_name) = os.path.split(path)
            (base_name, extension) = os.path.splitext(tmp_file_name)
            suffix = extension.strip()

            if suffix.lower() == ".qch":
                dst_path = os.path.join("E:/assistant", tmp_file_name)
                shutil.copy(path, dst_path)

    pass


if __name__ == '__main__':
    print("=================Start Extract *.qch --Qt Assistant")

    extract_qch(r"E:\qt-src\qt5.9.4_x64")
    print("=================Extract *.qch -- Qt Assistant finished")

 编译完成后需要将openssl 和icu的库拷贝到目标bin下

xcopy /y /k "%icu_path%\bin\icudt58.dll" "%dst_path%\bin\" 
xcopy /y /k "%icu_path%\bin\icuin58.dll" "%dst_path%\bin\" 
xcopy /y /k "%icu_path%\bin\icuio58.dll" "%dst_path%\bin\" 
xcopy /y /k "%icu_path%\bin\icutest58.dll" "%dst_path%\bin\" 
xcopy /y /k "%icu_path%\bin\icutu58.dll" "%dst_path%\bin\" 
xcopy /y /k "%icu_path%\bin\icuuc58.dll" "%dst_path%\bin\" 
xcopy /y /k "%icu_path%\lib\icudt.lib" "%dst_path%\lib\" 
xcopy /y /k "%icu_path%\lib\icuin.lib" "%dst_path%\lib\" 
xcopy /y /k "%icu_path%\lib\icuio.lib" "%dst_path%\lib\" 
xcopy /y /k "%icu_path%\lib\icutest.lib" "%dst_path%\lib\" 
xcopy /y /k "%icu_path%\lib\icutu.lib" "%dst_path%\lib\" 
xcopy /y /k "%icu_path%\lib\icuuc.lib" "%dst_path%\lib\" 

xcopy /y /k "%openssl_path%\bin\libeay32.dll" "%dst_path%\bin\" 
xcopy /y /k "%openssl_path%\bin\ssleay32.dll" "%dst_path%\bin\" 
xcopy /y /k "%openssl_path%\lib\libeay32.lib" "%dst_path%\lib\" 
xcopy /y /k "%openssl_path%\lib\ssleay32.lib" "%dst_path%\lib\"

添加帮助文档:

打开目标bin下的assistant.exe,点击Edit->Preference->Document->Add, 添加抽取出来的帮助文档(*.qch), 点击刷新。

测试:

1. widget模块测试;

2. webengine模块测试;

3. vs导入pro工程文件测试;

4. vs导出pro工程文件测试;

5. 翻译测试;

注:编译完成后,不要随意更改目标路径;

下面的链接中含有编译依赖及Qt5.9.4编译完成后的文件:

链接:https://pan.baidu.com/s/1jvuUKcAtKaBrV5hO0zN9VQ 
提取码:o0ti 

 

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值