[英]How to build Qt 6.2.2 from source on Windows 10
我一直在嘗試從源代碼構建 Qt 6.2.2。 我從在線安裝程序下載了 package 源代碼,但每次都失敗,每次都出現不同的錯誤。 我嘗試了各種配置,例如:
configure.bat -static -release -platform win32-msvc -opensource -confirm-license -prefix "C:\Qt\6.2.2\Static" -make libs -make tools -nomake examples -nomake tests
configure.bat -static -release -platform win32-msvc -opensource -confirm-license -prefix "C:\Qt\6.2.2\Static" -make libs -make tools -nomake examples -nomake tests -no-icu -no-opengl -no-openssl -skip qtwayland -skip qtquick3d -skip qtquickcontrols2 -skip qtquicktimeline -skip qtshadertools -skip qtdeclarative -skip qtdoc -skip qttranslations -skip qt3d -skip qt5compat -skip qtcharts -skip qtcoap -skip qtdatavis3d -skip qtlottie -skip qtmqtt -skip qtopcua -skip qtscxml -skip qtvirtualkeyboard -skip qtmultimedia -skip qtwebengine -skip qtwebview
configure.bat -static -release -platform win32-msvc -opensource -confirm-license -prefix "C:\Qt\6.2.2\Static" -no-openssl -make libs -make tools -nomake examples -nomake tests
我嘗試使用 VS 2017 的 x86_x64 交叉工具命令提示符、VS 2019 的 x86_x64 交叉工具命令提示符和 VS 2019 的 x64 本機工具命令提示符
這是我使用所有配置選項時遇到的錯誤之一,然后cmake --build.
[1424/8836] Building CXX object
qtbase\src\network\CMakeFiles\Network.dir\Network_autogen\mocs_compilation.cpp.obj
FAILED:
qtbase/src/network/CMakeFiles/Network.dir/Network_autogen/mocs_compilation.cpp.obj
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1424~1.283\bin\Hostx86\x64\cl.exe
/nologo /TP -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT -DQT_BUILD_NETWORK_LIB -
DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -
DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DQT_MOC_COMPAT -DQT_NO_CAST_TO_ASCII -
DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -
DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_USING_NAMESPACE -
DQT_USE_QSTRINGBUILDER -DQT_USE_SYSTEM_PROXIES -DUNICODE -DWIN32 -DWIN64 -
D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -
D_USE_MATH_DEFINES -D_WIN64 -
IC:\Qt\6.2.2\Src\qtbase\src\network\Network_autogen\include -
IC:\Qt\6.2.2\Src\qtbase\include -IC:\Qt\6.2.2\Src\qtbase\include\QtNetwork -
IC:\Qt\6.2.2\Src\qtbase\src\network -IC:\Qt\6.2.2\Src\qtbase\src\network\kernel -
IC:\Qt\6.2.2\Src\qtbase\include\QtNetwork\6.2.2 -
IC:\Qt\6.2.2\Src\qtbase\include\QtNetwork\6.2.2\QtNetwork -
IC:\Qt\6.2.2\Src\qtbase\src\network\..\3rdparty\zlib\src -
IC:\Qt\6.2.2\Src\qtbase\include\QtCore -IC:\Qt\6.2.2\Src\qtbase\mkspecs\win32-msvc -
IC:\Qt\6.2.2\Src\qtbase\src\corelib -IC:\Qt\6.2.2\Src\qtbase\include\QtCore\6.2.2 -
IC:\Qt\6.2.2\Src\qtbase\include\QtCore\6.2.2\QtCore -IC:\Strawberry\c\include /DWIN32
/D_WINDOWS /DNDEBUG -O2 -MD /W3 /wd4530 /wd4577 -Zc:__cplusplus -permissive- -utf-8 -
FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding
-Zc:externConstexpr -Zc:wchar_t -guard:cf -std:c++17
/YuC:/Qt/6.2.2/Src/qtbase/src/network/CMakeFiles/Network.dir/cmake_pch.hxx
/FpC:/Qt/6.2.2/Src/qtbase/src/network/CMakeFiles/Network.dir/./cmake_pch.cxx.pch
/FIC:/Qt/6.2.2/Src/qtbase/src/network/CMakeFiles/Network.dir/cmake_pch.hxx
/showIncludes
/Foqtbase\src\network\CMakeFiles\Network.dir\Network_autogen\mocs_compilation.cpp.obj
/Fdqtbase\lib\Qt6Network.pdb /FS -c
C:\Qt\6.2.2\Src\qtbase\src\network\Network_autogen\mocs_compilation.cpp
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\memory(1764): error C2027:
use of undefined type 'QSslCipherPrivate'
C:\Qt\6.2.2\Src\qtbase\include\QtNetwork\../../src/network/ssl/qsslcipher.h(56):
note: see declaration of 'QSslCipherPrivate'
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\memory(1763): note: while
compiling class template member function 'void
std::default_delete<QSslCipherPrivate>::operator ()(_Ty *) noexcept const'
with
[
_Ty=QSslCipherPrivate
]
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\memory(1873): note: see
reference to function template instantiation 'void
std::default_delete<QSslCipherPrivate>::operator ()(_Ty *) noexcept const' being
compiled
with
[
_Ty=QSslCipherPrivate
]
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\memory(1802): note: see
reference to class template instantiation 'std::default_delete<QSslCipherPrivate>'
being compiled
C:\Qt\6.2.2\Src\qtbase\include\QtNetwork\../../src/network/ssl/qsslcipher.h(87):
note: see reference to class template instantiation
'std::unique_ptr<QSslCipherPrivate,std::default_delete<QSslCipherPrivate>>' being
compiled
C:\Qt\6.2.2\Src\qtbase\include\QtCore\../../src/corelib/kernel/qmetatype.h(2168):
note: see reference to class template instantiation 'std::array<char,38>' being
compiled
C:\Qt\6.2.2\Src\qtbase\src\network\access\qnetworkaccesscache_p.h(127): note: see
reference to function template instantiation 'std::array<char,38>
QtPrivate::typenameHelper<QNetworkAccessCache::CacheableObject*>(void)' being
compiled
C:\Qt\6.2.2\Src\qtbase\include\QtCore\../../src/corelib/kernel/qmetatype.h(2168):
note: see reference to class template instantiation 'std::array<char,28>' being
compiled
C:\Qt\6.2.2\Src\qtbase\include\QtNetwork\../../src/network/access/
qnetworkreply.h(197):
note: see reference to function template instantiation 'std::array<char,28>
QtPrivate::typenameHelper<QNetworkReply::NetworkError>(void)' being compiled
C:\Qt\6.2.2\Src\qtbase\include\QtCore\../../src/corelib/kernel/qmetatype.h(2168):
note:
see reference to class template instantiation 'std::array<char,31>' being compiled
C:\Qt\6.2.2\Src\qtbase\include\QtNetwork\../../src/network/ssl/
qsslpresharedkeyauthentica
tor.h(94): note: see reference to function template instantiation
'std::array<char,31>
QtPrivate::typenameHelper<QSslPreSharedKeyAuthenticator*>(void)' being compiled
C:\Qt\6.2.2\Src\qtbase\include\QtCore\../../src/corelib/kernel/qmetatype.h(2376):
note:
see reference to class template instantiation 'std::array<char,30>' being compiled
C:\Qt\6.2.2\Src\qtbase\include\QtCore\../../src/corelib/kernel/qmetatype.h(1587):
note:
see reference to class template instantiation 'std::array<char,9>' being compiled
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\memory(1764): error C2338:
can't
delete an incomplete type
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\memory(1765): warning C4150:
deletion of pointer to incomplete type 'QSslCipherPrivate'; no destructor called
C:\Qt\6.2.2\Src\qtbase\include\QtNetwork\../../src/network/ssl/qsslcipher.h(56):
note:
see declaration of 'QSslCipherPrivate'
[1426/8836] Building CXX object
qtbase\src\tools\qvkgen\CMakeFiles\qvkgen.dir\qvkgen.cpp.obj
ninja: build stopped: subcommand failed.
我還從這里下載了 5.15.x 源代碼,我可以使用我發布的第一個配置命令毫無問題地構建它。
我目前有草莓 Perl 5.32.x、python 3.10、3.9.x 和 Cmake 3.22.1 它們都安裝在我的路徑中據此,我符合要求。 我確認使用 where <insert_name.exe> 返回的路徑是正確的:
where perl.exe
C:\Strawberry\perl\bin\perl.exe
where python.exe
C:\Users\MyNAme\AppData\Local\Programs\Python\Python39\python.exe
C:\Users\MyName\AppData\Local\Programs\Python\Python310\python.exe
where cmake.exe
C:\Program Files\CMake\bin\cmake.exe
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
當我寫這篇文章時,我一直在挖掘並發現了大量關於同一問題的錯誤報告。 似乎都回到了 OpenSSL。 我抓住了 OpenSSL 源,我安裝了 NASM 並將其添加到我的路徑中。 我配置並構建了 OpenSSL :
perl Configure VC-WIN64A
nmake all
一旦 OpenSSL 完成重新配置 Qt :
configure.bat -prefix "C:\Libraries\QT-Static" -release -platform win32-msvc -opensource -confirm-license -make libs -make tools -nomake examples -nomake tests -I "C:\Program Files\OpenSSL\include\openssl" -L "C:\Program Files\OpenSSL\lib"
這次它顯示以下內容:
Qt Network:
getifaddrs() ........................... no
IPv6 ifname ............................ no
libproxy ............................... no
Schannel ............................... yes
OpenSSL ................................ yes
Qt directly linked to OpenSSL ........ no
OpenSSL 1.1 ............................ yes
DTLS ................................... yes
OCSP-stapling .......................... yes
SCTP ................................... no
Use system proxies ..................... yes
GSSAPI ................................. no
Brotli Decompression Support ........... no
然后跑:
cmake --build . --parallel
它仍然失敗,但這次出現了更多錯誤,再次鏈接回 OpenSSL 問題。 我想這可能與 CMAKE_CXX_STANDARD 標志有關,所以我強制 17 而不是讓 MSVC 強制最新但沒有運氣。 有沒有人設法讓 6.2.2 在 windows 10 上構建,如果是這樣怎么辦?
將編譯器升級到最新的 VS2019 版本 (16.11) - 另請參閱https://bugreports.qt.io/browse/QTBUG-97999
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.