一、手动编译openssl

    如果你不需要openssl的话,这一部分可以跳过。

    我的版本是:openssl1.1.1d

    下载地址:https://www.openssl.org/source/

    1. 准备工作

        下载openssl并解压,下载perl、nasm并安装。

        perl和nasm安装好后检查一下环境变量,有没有自动添加,没有的话手动添加一下

        

        看了几篇文章说还需要下载dmake,如果要编静态库是必要的,但在我的环境下测试不需要dmake也可以编译。

    2. 解压openssl

        将openssl解压到自己制定的目录,我的路径为 D:\third_party\openssl\openssl1.1.1d

        接下来就开始编译openssl

    3. 打开VS 2017命令窗口

        这里有个需要注意的,之前由于位数不对,在编译Qt,执行configure命令的时候踩了个坑,如果你想编译64位的,就打开VS2017 x64的命令窗口,在configure的时候也要去指定生成64位的库,编译Qt的时候,也要用x64的命令窗口。

        

    然后将路径切换到刚刚解压的目录:

d:
cd D:\third_party\openssl\openssl1.1.1d

    4. 执行configure命令

perl configure VC-WIN64A shared no-asm

        64位选择:VC-WIN64A 或  VC-WIN64I

        32位选择:VC-WIN32 (记得命令窗口也要换成32位的,编译Qt的时候也用32位的命令窗口)

    5. 执行nmake命令

nmake

    6. 执行nmake test命令,看是否通过

nmake test
//这一步可能会卡在70-test_comp.t,无关紧要,直接Crtl+c即可

    7. 执行nmake install

nmake install

        这一步是为了将相关文件输出到指定文件夹,如果没有指定的话默认为C:\Program Files\OpenSSl,或C:\Program Files(x86)\OpenSSl

        注意:这个路径在编译Qt的时,configure这一步会出错,因为Program Files之间有空格,识别出错。我这里没有指定输出目录,所以我手动将OpenSSL目录拷贝到了C盘下(C:\OpenSSL)

        如果想指定目录,configure时用--prefix配置项即可。

perl configure --prefix=D:\OpenSSL

    8. 查看输出目录

    

     

     

    这里会生成两个lib文件,编译Qt时会用到。dll文件在bin目录下 

    9. 查看版本

        还可以到bin目录下去查看版本的相关信息

C:
cd OpenSSL\bin
openssl version -a

        结果如下:

        

        至此,openssl就编译成功了!请记住你的输出目录(C:\OpenSSL) 

 

二、编译Qt

    我的版本是:Qt5.14.0

    请先下载好qt-everywhere-src-5.14.0,下载地址是:http://download.qt.io/archive/

    然后解压到指定目录,我的目录路径是:D:\Qt\Qt5.14.0

1. 打开VS 2017的x64命令窗口,并切换到D:\Qt\Qt5.14.0

2. 执行configure命令

    (我不确定Windows下的命令窗口在后面加 "\"是否有效,我也懒得试了,哈哈,这样写只是为了方便看,不然命令全显示在一行了,如果不行麻烦手动把 "\"和回车删掉)

.\configure -opensource -platform win32-msvc -developer-build -mp -release -v \
-confirm-license -nomake examples -nomake tests -nomake tools -no-iconv -no-dbus -no-plugin-manifests -no-opengl \
OPENSSL_PREFIX=C:\OpenSSL -openssl-linked -I  C:\OpenSSL\include -L C:\OpenSSL\lib OPENSSL_LIBS="libssl.lib libcrypto.lib Ws2_32.lib  Gdi32.lib Advapi32.lib Crypt32.lib User32.lib" -skip qt3d -skip qtactiveqt \
-skip qtandroidextras -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative \
-skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlottie \
-skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing \
-skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline \
-skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus \
-skip qtserialport -skip qtspeech -skip qttools -skip qtvirtualkeyboard -skip qtwayland \
-skip qtwebchannel -skip qtwebengine -skip qtwebglplugin -skip qtwebsockets \
-skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns \
-no-feature-appstore-compliant -no-feature-bearermanagement -no-feature-commandlineparser \ -no-feature-ftp -no-feature-future -no-feature-geoservices_esri -no-feature-gestures \
-no-feature-gssapi -no-feature-jalalicalendar -no-feature-sqlmodel -no-feature-sspi \
-no-feature-udpsocket

    1) 关于configure指令的相关信息,可以使用configure -help获取

    2) 我这里skip了很多项,都是Qt源码下的目录,除了qtbase、qtcharts、qtsvg等我用到的,其余的几乎全部skip了,如果你需要这些,不要skip

    3) configure -list-features可以列出所有的feature,如果你不需要,可以用-no-feature-udpsocket这样的形式来过滤,udpsocket是一个feature

    4) openssl-linked的坑

        最开始configure的时候,总是会报如下的错:

        基本上就是由于上面提到的位数问题引起的,像上面提到的注意即可。

        还有一个就是在OPENSSL_LIBS后面,除了编译openssl生成的两个库libssl.lib libcrypto.lib外,还有几个需要加上,跟我的configure命令保持一致就行了。

    5) configure成功

        configure成功,显示如下:

        

        上面还有build option的一些信息,就不贴图了。 

3. 开始编译

    执行nmake命令编译,大约等待二十分钟左右就好了(因为我configure时省略了很多)

nmake

4. 编译成功

    编译完成后,生成的库文件会出现在你qt文件夹下qtbase的lib目录下 (我的:D:\Qt\Qt5.14.0\qtbase\lib)

     

至此,手动编译Qt 就完成了。

和Qt原生的对比:

每个库都变小了一点,gui最为明显。至于具体configure的时候怎么取舍,去适配自己的项目,我还在研究当中。。。

希望这篇记录自己编译Qt过程的博客对你有帮助,如果有问题也欢迎指正。

GitHub 加速计划 / ope / openssl
20
1
下载
传输层安全性/安全套接层及其加密库
最近提交(Master分支:3 个月前 )
5b94140b Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/26462) 2 天前
1dafff06 When a requested parameter has a non-NULL result pointer, and the error isn't simply that the result buffer is too small, don't return a non-zero result size. Returning a non-zero result size that isn't larger than the user's provided space is an indication that a result of that size was actually written, inviting trouble if the error indication was inadvertenly lost. Also, in such cases (wrong type, data can't be converted to the requested type when otherwise supported, ...) there is nothing useful to be done with the return size value, it can't help to address the problem. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Paul Dale <ppzgs1@gmail.com> (Merged from https://github.com/openssl/openssl/pull/26436) 2 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐