qt5.12.10 vs2019编译静态库

1.背景

    以前使用MFC做界面,但是美化开发成本高,难度大,而且效果不理想,所以想采用QT实现。同时使用现有的dll库方式打包输出,依赖库大,而且输出文件多。所以通过静态最小编译的方式。实现输出单一最小UI exe模块。

2.源码选择和版本

    编译源文件选择市面上版本比较稳定的是5.12.10。需要下载QT源码和程序,进入

QT版本下:

https://download.qt.io/archive/qt/  进入版本,选择single

qt源码版本:http://mirrors.ustc.edu.cn/qtproject/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz

 

https://blog.csdn.net/skyloveka/article/details/108130252

 

2.QT剪裁

https://blog.csdn.net/ZCShouCSDN/article/details/76037463

参数含义:https://blog.csdn.net/kunkliu/article/details/79149371

2.编译环境搭建

编译工具安装

编译需要的环境可以看官方文档,windows-requirements 中的Building from Source有说明需要安装的工具,所有工具都记得要添加到环境变量。

Qt5-12-5-static-build-2020-07-11-22-37-34

  1. VS2019(其他版本仅作参考),下载地址:Visual Studio 2019
  2. ActivePerl, 下载地址:Download And Install Perl: ActivePerl
  3. Python,下载地址:Python Releases for Windows
  4. Ruby(以前的官方文档是有的,如果有问题可以装下),下载地址:RubyInstaller for Windows
  5. Jom,多核编译,下载地址:jom releases

3.编译准备

  1. 源码下载并解压,下载地址:qt-everywhere-src-5.12.5.zip
  2. 在源码同级目录创建个 qt-build 目录来放生成的文件,也就是使用shadow build,方便修改配置后进行多配置编译。直接运行源码目录下的 configure.bat 会把生成文件生成到源码目录,修改配置后编译容易出错。
.\..\src\configure.bat -static -release -platform win32-msvc -release -static -prefix "D:\Qt\Qt5.12.5-msvc2019-x86-static-release-full" -opensource -confirm-license -nomake examples -nomake tests -plugin-sql-sqlite -plugin-sql-odbc -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -mp
jom           
nmake install

4.编译命令

"..\src\configure.bat" -static -debug-and-release -platform win32-msvc -release -static -prefix "D:\Qt\Q6.1.0-msvc2019-x64-static-release-full" -opensource -confirm-license -nomake examples -nomake tests -plugin-sql-sqlite -plugin-sql-odbc -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -m

 

"../qt-everywhere-src-5.12.10/configure.bat" -static\
 -debug-and-release -platform win32-msvc\
 -no-opengl -prefix "D:\Qt\Qt5.12.10-msvc2019-x64-static-md-release-mini"\
-opensource -confirm-license -make libs -nomake tools  \
-nomake examples -nomake tests -skip qt3d \
-skip qtandroidextras -skip qtcanvas3d \
-skip qtconnectivity -skip qtdatavis3d \
-skip qtdeclarative -skip qtdoc \
-skip qtgamepad -skip qtcharts \
-skip qtgraphicaleffects \
-skip qtimageformats -skip qtlocation \
-skip qtmacextras -skip qtmultimedia \
-skip qtnetworkauth -skip qtpurchasing \
-skip qtquickcontrols -skip qtquickcontrols2 \
-skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtspeech 
-skip qtsvg -skip qttools -skip qttranslations -skip qtvirtualkeyboard \
-skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets \
-skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns \
-no-feature-texthtmlparser -no-feature-textodfwriter -no-feature-concurrent \
-no-feature-effects -no-feature-sharedmemory -no-feature-systemsemaphore \
-no-feature-im -no-feature-dom -no-feature-filesystemwatcher -no-feature-graphicsview \
-no-feature-graphicseffect -no-feature-sizegrip -no-feature-printpreviewwidget \
-no-feature-keysequenceedit -no-feature-colordialog -no-feature-fontdialog -no-feature-printpreviewdialog \
-no-feature-progressdialog -no-feature-errormessage -no-feature-wizard -no-feature-datawidgetmapper \
-no-feature-cups -no-feature-paint_debug -no-feature-codecs -no-feature-big_codecs -no-feature-iconv \
-no-feature-networkproxy -no-feature-socks5 -no-feature-networkdiskcache -no-feature-bearermanagement \
-no-feature-mimetype -no-feature-undocommand -no-feature-undostack -no-feature-undogroup \
-no-feature-undoview -no-feature-statemachine -no-feature-gestures -no-feature-dbus \
-no-feature-sessionmanager -no-feature-topleveldomain -no-feature-sha3-fast -no-feature-imageformat_ppm \
-no-feature-imageformat_xbm -no-feature-freetype -no-feature-appstore-compliant -no-feature-process 
-no-feature-lcdnumber -qt-zlib -qt-libpng -qt-libjpeg  -no-sql-driver -no-zlib -no-webkit -no-openssl -no-gif  -no-phonon -no-qt3support \
-no-sqlite  -no-largefile -no-exceptions

Qt5-12-5-static-build-2020-07-11-22-47-19

  1. 修改qtbase\mkspecs\common\msvc-desktop.conf文件,将 MD 改为 MT

Qt5-12-5-static-build-2020-07-12-00-27-17

  1. 打开 VS 的命令行工具并切换到第 2 步创建的 qt-build 目录,后面就是输入命令编译了。

 

Qt5-12-5-static-build-2020-07-12-00-29-11

 

https://www.jianshu.com/p/192cfe3d9b30

VS2017编译32位/64位QT静态库 https://blog.csdn.net/weixin_35857412/article/details/94738666

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编译 Qt 5.12.12 源码时,需要先编译 OpenSSL ,并将其加入 Qt编译选项中。以下是静态编译 Qt 5.12.12 包括 OpenSSL 的步骤: 1. 下载并编译 OpenSSL 您可以从 OpenSSL 官网下载最新的源码包,例如 `openssl-1.1.1i.tar.gz`。下载后,解压缩并进入目录,执行以下命令进行编译: ``` ./config no-shared --prefix=/path/to/openssl make && make install ``` 其中,`/path/to/openssl` 为您安装 OpenSSL 的路径。 2. 下载并解压 Qt 5.12.12 源码 您可以从 Qt 官网下载 Qt 5.12.12 的源码包,例如 `qt-everywhere-src-5.12.12.tar.xz`。下载后,解压缩至任意目录。 3. 配置 Qt编译选项 进入 Qt 源码目录,执行以下命令进行配置: ``` ./configure -static -prefix /path/to/qt -openssl-linked OPENSSL_PREFIX=/path/to/openssl -no-openssl ``` 其中,`/path/to/qt` 为您要安装 Qt 的路径,`/path/to/openssl` 为您安装 OpenSSL 的路径。 此命令中,`-static` 表示静态编译,`-prefix` 指定 Qt 安装路径,`-openssl-linked` 表示链接 OpenSSL ,`OPENSSL_PREFIX` 指定 OpenSSL 的安装路径,`-no-openssl` 表示不使用 Qt 自带的 OpenSSL 。 4. 编译 Qt 执行以下命令进行编译: ``` make -j4 ``` 其中,`-j4` 表示使用 4 个线程进行编译,可以根据自己的 CPU 核心数进行调整。 5. 安装 Qt 执行以下命令进行安装: ``` make install ``` 此命令会将编译好的 Qt 安装至指定路径。 至此,静态编译 Qt 5.12.12 并包括 OpenSSL 完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值