cmake 6.3.2编制发行Qt

eivnm1vs  于 2022-11-11  发布在  其他
关注(0)|答案(1)|浏览(162)

我想构建Qt 6.3.2,但在编译过程中遇到了很多问题。
我使用以下库来构建Qt:
1.数据库管理系统(MySQL)
1.开放式安全套接字协议(OpenSSL-1.1.1q)

  1. Zlib(zlib-win-build-1.2.12)程式码

我的cmake批处理命令:

cmake.exe --trace-expand --trace-redirect=cmake.trace -DCMAKE_BUILD_TYPE=%qtBuildMode% -DBUILD_SHARED_LIBS=OFF -DQT_BUILD_EXAMPLES=OFF -DCMAKE_PREFIX_PATH="C:\\LLVM\\x64\\static\\debug;" -DZLIB_INCLUDE_DIR="C:\\ZipDev\\zlib-win-build-1.2.12" -DZLIB_LIBRARY="C:\\ZipDev\\zlib-win-build-1.2.12\\build-VS2022-MT\\x64\\Debug\\libz-static.lib" -DZLIB_USE_STATIC_LIBS=ON -DINPUT_static_runtime=ON -DFEATURE_ltcg=OFF -DBUILD_qtwebengine=OFF -DOPENSSL_ROOT_DIR="%qtBuildOpenSSLRootPath%" -DFEATURE_openssl_linked=ON -DOPENSSL_USE_STATIC_LIBS=TRUE -DOPENSSL_MSVC_STATIC_RT=TRUE -DINPUT_sql_mysql=ON -DMySQL_INCLUDE_DIR="%qtBuildMySqlIncludeDirsPath%" -DMySQL_LIBRARY="%qtBuildMySqlLibsPath%" -DCMAKE_INSTALL_PREFIX="%qtBuildPath%" -G Ninja %qtBuildSourcePath%

我已经修复了很多,但仍然需要修复这一个。

[7197/9220] Linking CXX executable qtbase\bin\assistant.exe
FAILED: qtbase/bin/assistant.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=qttools\src\assistant\assistant\CMakeFiles\assistant.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~3\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\assistant.rsp  /out:qtbase\bin\assistant.exe /implib:qttools\src\assistant\assistant\assistant.lib /pdb:qtbase\bin\assistant.pdb /version:0.0 /machine:x64 /debug /subsystem:windows  -DYNAMICBASE -NXCOMPAT -LARGEADDRESSAWARE  && cd ."
LINK: command "C:\PROGRA~2\MICROS~3\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\assistant.rsp /out:qtbase\bin\assistant.exe /implib:qttools\src\assistant\assistant\assistant.lib /pdb:qtbase\bin\assistant.pdb /version:0.0 /machine:x64 /debug /subsystem:windows -DYNAMICBASE -NXCOMPAT -LARGEADDRESSAWARE /MANIFEST /MANIFESTFILE:qtbase\bin\assistant.exe.manifest" failed (exit code 1120) with the following output:
   Creating library qttools\src\assistant\assistant\assistant.lib and object qttools\src\assistant\assistant\assistant.exp
mysqlclientMTd.lib(charset.obj) : error LNK2019: unresolved external symbol __std_init_once_link_alternate_names_and_abort referenced in function "void __cdecl std::call_once<void (__cdecl&)(void)>(struct std::once_flag &,void (__cdecl&)(void))" (??$call_once@A6AXXZ$$V@std@@YAXAEAUonce_flag@0@A6AXXZ@Z)
mysqlclientMTd.lib(my_malloc.obj) : error LNK2001: unresolved external symbol __std_init_once_link_alternate_names_and_abort
qtbase\bin\assistant.exe : fatal error LNK1120: 1 unresolved externals
[7206/9220] Building CXX object qttools\src\designer\src\designer\CMakeFiles\designer.dir\cmake_pch.cxx.obj
ninja: build stopped: subcommand failed.

你知道是什么原因导致这样的错误吗?谢谢。

juzqafwq

juzqafwq1#

mysqlclientMTd.lib出现此问题是由于编译器版本之间不匹配所致,如下所述:https://developercommunity.visualstudio.com/t/__imp___std_init_once_complete-unresolve/1684365。这个库是用Visual Studio 2022编译器编译的。我用x64 Native Tools Command Prompt for VS 2019编译了Qt 6.3.2,这意味着它找不到这个新函数:__std_init_once_link_alternate_names_and_abort。此函数来自STL的导入库:msvcprt.lib,仅在VS 2022版本中添加:17.2.5。因此,我通过为VS 2019编译器重新构建此mysqlclientMTd.lib修复了此错误,因为我需要VS 2019编译器的Qt 6.3.2
此外,我还得到了另一个错误,在这个时候与libz-static.lib在发布版本:

C:\QtBuild\qt-everywhere-src-6.3.2>cmake --build .
[792/9220] Linking CXX executable qtbase\bin\rcc.exe
FAILED: qtbase/bin/rcc.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=qtbase\src\tools\rcc\CMakeFiles\rcc.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~3\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo qtbase\src\tools\rcc\CMakeFiles\rcc.dir\rcc_autogen\mocs_compilation.cpp.obj qtbase\src\tools\rcc\CMakeFiles\rcc.dir\rcc_resource.rc.res qtbase\src\tools\rcc\CMakeFiles\rcc.dir\main.cpp.obj qtbase\src\tools\rcc\CMakeFiles\rcc.dir\rcc.cpp.obj  /out:qtbase\bin\rcc.exe /implib:qtbase\src\tools\rcc\rcc.lib /pdb:qtbase\bin\rcc.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console  -DYNAMICBASE -NXCOMPAT -LARGEADDRESSAWARE -OPT:REF -OPT:ICF -GUARD:CF  qtbase\lib\Qt6Core.lib  qtbase\lib\Qt6Core.lib  C:\\ZipDev\\zlib-win-build-1.2.12\\build-VS2022-MT\\x64\\Release\\libz-static.lib  synchronization.lib  mpr.lib  userenv.lib  advapi32.lib  authz.lib  kernel32.lib  netapi32.lib  ole32.lib  shell32.lib  user32.lib  uuid.lib  version.lib  winmm.lib  ws2_32.lib  runtimeobject.lib  qtbase\lib\Qt6BundledPcre2.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK: command "C:\PROGRA~2\MICROS~3\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo qtbase\src\tools\rcc\CMakeFiles\rcc.dir\rcc_autogen\mocs_compilation.cpp.obj qtbase\src\tools\rcc\CMakeFiles\rcc.dir\rcc_resource.rc.res qtbase\src\tools\rcc\CMakeFiles\rcc.dir\main.cpp.obj qtbase\src\tools\rcc\CMakeFiles\rcc.dir\rcc.cpp.obj /out:qtbase\bin\rcc.exe /implib:qtbase\src\tools\rcc\rcc.lib /pdb:qtbase\bin\rcc.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console -DYNAMICBASE -NXCOMPAT -LARGEADDRESSAWARE -OPT:REF -OPT:ICF -GUARD:CF qtbase\lib\Qt6Core.lib qtbase\lib\Qt6Core.lib C:\\ZipDev\\zlib-win-build-1.2.12\\build-VS2022-MT\\x64\\Release\\libz-static.lib synchronization.lib mpr.lib userenv.lib advapi32.lib authz.lib kernel32.lib netapi32.lib ole32.lib shell32.lib user32.lib uuid.lib version.lib winmm.lib ws2_32.lib runtimeobject.lib qtbase\lib\Qt6BundledPcre2.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:qtbase\bin\rcc.exe.manifest" failed (exit code 1257) with the following output:
libz-static.lib(compress.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
fatal error C1900: Il mismatch between 'P1' version '20211014' and 'P2' version '20210202'
LINK : fatal error LNK1257: code generation failed
[800/9220] Automatic MOC for target Network
AutoMoc: C:/QtBuild/qt-everywhere-src-6.3.2/qtbase/src/network/access/qnetworkaccessdebugpipebackend_p.h(0:1): note: No relevant classes found. No output generated.
[801/9220] Building CXX object qtbase\src\tools\qlalr\CMakeFiles\qlalr.dir\cppgenerator.cpp.obj
ninja: build stopped: subcommand failed.

C:\QtBuild\qt-everywhere-src-6.3.2>

因此,要修复此错误,请执行以下操作:fatal error C1900: Il mismatch between 'P1' version '20211014' and 'P2' version '20210202',我必须为VS 2019编译器构建libz-static.lib。现在,所有的编译(调试/发布)都没有任何错误。问题解决了。

相关问题