本文主要是介绍VS2019加入VC-LTL编译Qt5.12.8去除VC运行时,支持WebEngine,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
由于QWebEngine只支持VS编译,在程序发布时各种VC运行时真的让人很崩溃,感谢初雨开源的VC_LTL让我们从VC运行时解脱出来。记录一下编译过程。
1.编译环境:
Windows10x64+VS2019社区版+Python2.7+Perl5.28.1+Ruby2.6.3+LLVM6.0; Qt5.12.8+ICU4C66+OpenSSl1.1.1d+VC-LTL4.1.0.2
2.编译脚本:
@echo offREM Set up \Microsoft Visual Studio 2015, where <arch> is \c amd64, \c x86, etc.
REM CALL "D:\Application\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
CALL "D:\Application\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat"REM Edit this location to point to the source code of Qt
SET _ROOT=F:\qt-everywhere-src-5.12.8SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%REM Uncomment the below line when using a git checkout of the source repository
SET PATH=%_ROOT%\qtrepotools\bin;%PATH%REM Uncomment the below line when building with OpenSSL enabled. If so, make sure the directory points
REM to the correct location (binaries for OpenSSL).
SET PATH=D:\QtDevKit\VS2019_VC_LTL_x86_OpenSSL\bin;%PATH%REM When compiling with ICU, uncomment the lines below and change <icupath> appropriately:
SET INCLUDE=D:\QtDevKit\VS2019_VC_LTL_x86_ICU4C66\include;%INCLUDE%
SET LIB=D:\QtDevKit\VS2019_VC_LTL_x86_ICU4C66\lib;%LIB%
SET PATH=D:\QtDevKit\VS2019_VC_LTL_x86_ICU4C66\lib;%PATH%
SET PATH=D:\QtDevKit\VS2019_VC_LTL_x86_ICU4C66\bin;%PATH%REM LLVM
SET LLVM_INSTALL_DIR=C:\Program Files\LLVM
SET PATH=C:\Program Files\LLVM\bin;%PATH%
REM Contrary to earlier recommendations, do NOT set QMAKESPEC.CD /D %_ROOT%REM call configure -prefix D:\QtDevKit\VS2019_VC-LTL_x86_Qt5.12.8_NoOpenGl -opensource -release -mp -nomake tests -nomake examples -platform win32-msvc -openssl-linked -ID:\QtDevKit\VS2019_VC_LTL_x86_OpenSSL\include -LD:\QtDevKit\VS2019_VC_LTL_x86_OpenSSL\lib OPENSSL_LIBS="-llibssl -llibcrypto" -ID:\QtDevKit\VS2019_VC_LTL_x86_ICU4C66\include -LD:\QtDevKit\VS2019_VC_LTL_x86_ICU4C66\lib -icuREM VC-LTL
REM qtbase\mkspecs\common\msvc-desktop.conf MD -> MT
SET PATH=D:\QtDevKit\VC_LTL4.1.0.2\Redist\x86;%PATH%
CALL "D:\QtDevKit\VC_LTL4.1.0.2\VC-LTL helper for nmake.cmd"REM Keeps the command line open when this script is run.
cmd /k
3.开始编译:
为了彻底摆脱VC运行时,首先编译ICU及OpenSSL;执行上面脚本(已加入VC-LTL),以MT方式编译完成就行。
修改QT文件:
\qtbase\mkspecs\common\msvc-desktop.conf,从MD改为MT
QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MT
QMAKE_CFLAGS_DEBUG = -Zi -MTd
\qtwebengine\src\3rdparty\chromium\build\config\win\BUILD.gn,从MD改为MT
config("release_crt") {if (is_component_build) {cflags = [ "/MT" ]} else {cflags = [ "/MT" ]}
}config("dynamic_crt") {if (is_debug) {# This pulls in the DLL debug CRT and defines _DEBUGcflags = [ "/MTd" ]} else {cflags = [ "/MT" ]}
}config("static_crt") {if (is_debug) {# This pulls in the static debug CRT and defines _DEBUGcflags = [ "/MTd" ]} else {cflags = [ "/MT" ]}
}
配置Qt编译过程,重点说明:(如是目标布署机器显卡老旧或不支持opengl,加上-no-opengl,否则在使用wegenginewidget时会黑屏等异常情况)
configure -prefix D:\QtDevKit\VS2019_VC-LTL_x86_Qt5.12.8_NoOpenGl -opensource -release -mp -nomake tests -nomake examples -platform win32-msvc -openssl-linked -ID:\QtDevKit\VS2019_VC_LTL_x86_OpenSSL\include -LD:\QtDevKit\VS2019_VC_LTL_x86_OpenSSL\lib OPENSSL_LIBS="-llibssl -llibcrypto" -ID:\QtDevKit\VS2019_VC_LTL_x86_ICU4C66\include -LD:\QtDevKit\VS2019_VC_LTL_x86_ICU4C66\lib -icu -no-opengl
这篇关于VS2019加入VC-LTL编译Qt5.12.8去除VC运行时,支持WebEngine的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!