firemail

标题: qt源码及编译相关问题 [打印本页]

作者: Qter    时间: 2020-3-15 20:57
标题: qt源码及编译相关问题
本帖最后由 Qter 于 2020-3-21 11:26 编辑

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


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

General Installation Information
Building 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:

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 目录


-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
编译用到的工具




动手先添加下依赖的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内容如下:
  1. REM Set up Microsoft Visual Studio 2019, where <arch> is amd64, x86, etc.
  2. CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat" x86
  3. SET _ROOT=F:\Qt\Qt-5
  4. SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
  5. 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


作者: Qter    时间: 2020-3-21 08:53
本帖最后由 Qter 于 2020-3-21 09:05 编辑

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

以根目录为 F:\qtbuild
先下载编译依赖库openssl
  1. git clone https://github.com/openssl/openssl.git openssl_1_1_1
  2. cd openssl_1_1_1
  3. git checkout OpenSSL_1_1_1-stable
  4. perl Configure no-shared debug-VC-WIN32
  5. nmake
  6. mkdir out32.dbg
  7. move libcrypto.lib out32.dbg
  8. move libssl.lib out32.dbg
  9. move ossl_static.pdb out32.dbg\ossl_static
  10. nmake clean
  11. move out32.dbg\ossl_static out32.dbg\ossl_static.pdb
  12. perl Configure no-shared VC-WIN32
  13. nmake
  14. mkdir out32
  15. move libcrypto.lib out32
  16. move libssl.lib out32
  17. move ossl_static.pdb out32
  18. cd ..
复制代码
下载qt编译
  1. git clone git://code.qt.io/qt/qt5.git qt_5_12_5
  2. cd qt_5_12_5
  3. perl init-repository --module-subset=qtbase,qtimageformats
  4. git checkout v5.12.5
  5. git submodule update qtbase
  6. git submodule update qtimageformats
  7. cd qtbase
  8. git apply ../../patches/qtbase_5_12_5.diff
  9. cd ..

  10. 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

  11. jom -j4
  12. jom -j4 install
  13. cd ..
复制代码

作者: Qter    时间: 2020-3-21 14:01

F:\qtbuild_github\qt_5_12_5>which link
/usr/bin/link
作者: Qter    时间: 2020-3-22 17:32
ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && libs.openssl' failed.

删除目录下的config.cache




欢迎光临 firemail (http://www.firemail.wang:8088/) Powered by Discuz! X3