windows 使用clang编译qt-6.9.1源代码

1.下载qt-everywhere-6.9.1.tar.xz

2.解压到磁盘

3.打开windows vs msvc工具shell

4.安装最新版llvm 我当前版本是20.1.7

https://github.com/llvm/llvm-project/tree/llvmorg-20.1.7

5.

configure.bat -release -confirm-license -opensource -prefix "D:\software\Qt" -platform win32-clang-msvc -nomake examples -nomake tests -skip qtmqtt -skip qtopcua  -skip qtquick3dphysics -skip qtquickeffectmaker -shared
+ D:\qt-everywhere-src-6.9.1/qtbase/configure.bat -top-level -release -confirm-license -opensource -prefix D:\software\Qt -platform win32-clang-msvc -nomake examples -nomake tests -skip qtmqtt -skip qtopcua -skip qtquick3dphysics -skip qtquickeffectmaker -shared

configure.bat -release -confirm-license -opensource -prefix "D:\software\Qt" -platform win32-clang-msvc -shared -nomake examples -nomake tests -skip qtmqtt -skip qtopcua  -skip qtquick3dphysics -skip qtquickeffectmaker

或者

cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DQT_BUILD_SUBMODULES=qtbase -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DBUILD_WITH_PCH=OFF -DQT_BUILD_TOOLS_BY_DEFAULT=OFF -DFEATURE_precompile_header=OFF -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl

6. 运行

>cmake --build . --parallel

==========cut line here=====================================================


[198/1802] Building CXX object qtbase\src\entrypoint\CMakeFiles\EntryPointImplementation.dir\qtentrypoint_win.cpp.obj
D:\qt-everywhere-src-6.9.1\qtbase\src\entrypoint\qtentrypoint_win.cpp(21,16): warning: 'main' should not be 'extern "C"' [-Wmain]
   21 | extern "C" int main(int, char **);
      |                ^
1 warning generated.
[501/1802] Building CXX object qtbase\src\corelib\CMakeFiles\Core.dir\global\qlibraryinfo.cpp.obj
D:\qt-everywhere-src-6.9.1\qtbase\src\corelib\global\qlibraryinfo.cpp(310,16): warning: unused function 'getWindowsModuleHandle' [-Wunused-function]
  310 | static HMODULE getWindowsModuleHandle()
      |                ^~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
[1515/1802] Building CXX object qtbase\src\widgets\CMakeFiles\Widgets.dir\styles\qstyleoption.cpp.obj
D:\qt-everywhere-src-6.9.1\qtbase\src\widgets\styles\qstyleoption.cpp(864,32): warning: implicit truncation from 'Qt::TextElideMode' to bit-field changes value from 3 to -1 [-Wbitfield-constant-conversion]
  864 | : QStyleOptionHeader(version), textElideMode(Qt::ElideNone), isSectionDragTarget(false), unused(0)
      |                                ^             ~~~~~~~~~~~~~
1 warning generated.
[1541/1802] Building CXX object qtbase\src\plugins\platforms\direct2d\CMakeFiles\QWindowsDirect2DIntegrationPlugin.dir\__\windows\qwindowsglcontext.cpp.ob
D:\qt-everywhere-src-6.9.1\qtbase\src\plugins\platforms\windows\qwindowsglcontext.cpp(1350,128): warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
 1350 |         qCDebug(lcQpaGl) << __FUNCTION__ <<  procName << QOpenGLStaticContext::opengl32.wglGetCurrentContext() << "returns" << procAddress;
      |                                                                                                                                ^~~~~~~~~~~
1 warning generated.
[1737/1802] Building CXX object qtbase\src\plugins\platforms\windows\CMakeFiles\QWindowsIntegrationPlugin.dir\qwindowsglcontext.cpp.obj
D:\qt-everywhere-src-6.9.1\qtbase\src\plugins\platforms\windows\qwindowsglcontext.cpp(1350,128): warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
 1350 |         qCDebug(lcQpaGl) << __FUNCTION__ <<  procName << QOpenGLStaticContext::opengl32.wglGetCurrentContext() << "returns" << procAddress;
      |                                                                                                                                ^~~~~~~~~~~
1 warning generated.
[1802/1802] Linking CXX static library qtbase\plugins\styles\qmodernwindowsstyle.lib

========================================================================

7. cmake --install .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值