Qter 发表于 2020-3-15 20:57:48

qt源码及编译相关问题

本帖最后由 Qter 于 2020-3-21 11:26 编辑

https://code.qt.io/cgit/


https://doc.qt.io/qt-5/build-sources.html

General Installation InformationBuilding Qt revolves around using configure to configure Qt for a particular platform with a particular set of Qt features or modules. For more information, visit the following page:
[*]Qt Configure Options

configure 相关在源码根目录下运行 configure -h 查看相关命令,前提是在init-repository后,已经存在qtbase目录
注:windows平台configure对应是是configure.bat这个文件
mkdir qtbuild
cd qtbuild

configure -prefix "%LibrariesPath%\Qt-5.12.5
-prefix 指定编译后Qt程序和相关库的安装路径



-platform 设置编译主机平台.
常用如下:
configure.bat -platform win32-g++
configure.bat -platform win32-msvc

完整的列表查看qtbase/mkspecs 目录

[*]-device - a specific device or chipsets. The list of devices that configure is compatible with are found in qtbase/mkspecs/devices. For more information, visit the Devices Wiki page.


-mp .................. Use multiple processors for compilation (MSVC only)
-opensource .......... Build the Open-Source Edition of Qt


https://doc.qt.io/qt-5/windows-building.html
https://doc.qt.io/qt-5/windows-requirements.html

编译要求
Libraries

[*]OpenSSL Toolkit: Qt can make use of OpenSSL to support Secure Socket Layer (SSL) communication.
[*]ICU: Qt 5 can make use of the ICU library for enhanced UNICODE and Globalization support (see QTextCodec, QCollator::setNumericMode()).At compile time, the include and lib folders of the ICU installation must be appended to the INCLUDE and LIB environment variables. At run-time, the ICU DLLs need to be found by copying the DLLs to the application folder or by adding the bin folder of the ICU installation to the PATH environment variable.
[*]ANGLE: This library converts OpenGL ES 2.0 API calls to DirectX 11 or DirectX 9 calls (depending on availability), removing the need to install graphics drivers on the target machines.
编译用到的工具


[*]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.



动手先添加下依赖的PATH路径
D:\TBuild\ThirdParty\Perl\bin;D:\TBuild\ThirdParty\Python27;D:\TBuild\ThirdParty\jom;

在桌面上创建打开的快捷方式
右键->新建->快捷方式,输入如下内容
%SystemRoot%\system32\cmd.exe /E:ON /V:ON /k F:\Qt\qt5vars.cmd

qt5vars.cmd内容如下:REM Set up Microsoft Visual Studio 2019, where <arch> is amd64, x86, etc.
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat" x86
SET _ROOT=F:\Qt\Qt-5
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
SET _ROOT=
https://doc.qt.io/qt-5/windows-deployment.html

C:\Qt\Qt5.12.0\5.12.0\msvc2017\bin\windeployqt.exe查看qt程序的依赖文件

Static Linking
configure -static


重新配置和重建Qt 要输入如下命令,对原来的配置进行清理
nmake distclean


对Qt开发的程序的静态编译和动态编译
nmake clean
qmake -config release
nmake

https://wiki.qt.io/Building_Qt_5_from_Git

This article provides hints for checking out and building the Qt 5 repositories. This is primarily for developers who want to contribute to the Qt library itself, or who want to try the latest unreleased code.If you simply want to build a specific release of Qt from source to use the libraries in your own project, you can download the source code from the Official Releases page or the Archive. Alternatively, commercial customers can download the Source Packages via the Qt Account portal.

To compile Qt Creator, see Building Qt Creator from Git.
All desktop platforms
[*]Git (>= 1.6.x)
[*]Perl (>=5.14)
[*]Python (>=2.6.x)
[*]A working C++ compiler


Qter 发表于 2020-3-21 08:53:45

本帖最后由 Qter 于 2020-3-21 09:05 编辑

基于官方源码库qt_5_12_5 https://code.qt.io/cgit/的编译

以根目录为 F:\qtbuild
先下载编译依赖库openssl
git clone https://github.com/openssl/openssl.git openssl_1_1_1
cd openssl_1_1_1
git checkout OpenSSL_1_1_1-stable
perl Configure no-shared debug-VC-WIN32
nmake
mkdir out32.dbg
move libcrypto.lib out32.dbg
move libssl.lib out32.dbg
move ossl_static.pdb out32.dbg\ossl_static
nmake clean
move out32.dbg\ossl_static out32.dbg\ossl_static.pdb
perl Configure no-shared VC-WIN32
nmake
mkdir out32
move libcrypto.lib out32
move libssl.lib out32
move ossl_static.pdb out32
cd ..下载qt编译git clone git://code.qt.io/qt/qt5.git qt_5_12_5
cd qt_5_12_5
perl init-repository --module-subset=qtbase,qtimageformats
git checkout v5.12.5
git submodule update qtbase
git submodule update qtimageformats
cd qtbase
git apply ../../patches/qtbase_5_12_5.diff
cd ..

configure -prefix "%LibrariesPath%\Qt-5.12.5" -debug-and-release -force-debug-info -opensource -confirm-license -static -static-runtime -I "%LibrariesPath%\openssl_1_1_1\include" -no-opengl -openssl-linked OPENSSL_LIBS_DEBUG="%LibrariesPath%\openssl_1_1_1\out32.dbg\libssl.lib %LibrariesPath%\openssl_1_1_1\out32.dbg\libcrypto.lib Ws2_32.lib Gdi32.lib Advapi32.lib Crypt32.lib User32.lib" OPENSSL_LIBS_RELEASE="%LibrariesPath%\openssl_1_1_1\out32\libssl.lib %LibrariesPath%\openssl_1_1_1\out32\libcrypto.lib Ws2_32.lib Gdi32.lib Advapi32.lib Crypt32.lib User32.lib" -mp -nomake examples -nomake tests -platform win32-msvc

jom -j4
jom -j4 install
cd ..

Qter 发表于 2020-3-21 14:01:43


F:\qtbuild_github\qt_5_12_5>which link
/usr/bin/link

Qter 发表于 2020-3-22 17:32:14

ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && libs.openssl' failed.

删除目录下的config.cache
页: [1]
查看完整版本: qt源码及编译相关问题