Skip to content

Instantly share code, notes, and snippets.

@wen-long
Last active January 14, 2021 18:21
Show Gist options
  • Select an option

  • Save wen-long/4d34f7f850c0626af622 to your computer and use it in GitHub Desktop.

Select an option

Save wen-long/4d34f7f850c0626af622 to your computer and use it in GitHub Desktop.
  1. 慎看官网教程的这个教程 -> Building Qt Desktop for Windows with MinGW,有点坑爹,避重就轻的,浪费我好多时间,正在看的最好赶紧关掉,忘掉。

  2. 需要 MinGW,貌似需要 Python 和 Perl,我之前就有,所以不知道到底用到没

  3. Qt官网 下载 qt-everywhere-opensource-src-4.8.6.zip,带文件夹解压到C:\Qt,并在该位置打开 cmd

  4. 修改C:\Qt\Qt_everywhere-src_4.8.6\mkspecs\win32-g++\qmake.conf的 line 63 QMAKE_LFLAGS = -> QMAKE_LFLAGS = -static line 70 QMAKE_LFLAGS_DLL = -shared -> QMAKE_LFLAGS_DLL = -static

为的是避免出现缺失 libstdc++-6.dll 等的情况

  1. 创建文件夹 C:\Qt\Qt_4.8.6_static 并复制源码目录下的 mkspecs 目录到 C:\Qt\Qt_4.8.6_static

  2. 在之前打开的 cmd 中运行

configure 
-confirm-license 
-prefix "C:\Qt\Qt_4.8.6_static" 
-platform win32-g++ -opensource 
-debug-and-release 
-static 
-no-phonon 
-fast 
-nomake examples 
-nomake demos 
-no-dsp 
-no-vcproj 
-no-cetest 
-no-s60 
-qt-sql-odbc -qt-sql-sqlite -plugin-sql-odbc -plugin-sql-sqlite 
-no-qt3support -no-opengl -no-openvg -no-incredibuild-xge 
-nomake demos -nomake examples -nomake tests 
-no-webkit 
make -j4
make install

我这里用的是 msys2 的 make,你可以

>which make
/bin/make

看看用的是哪个 i5 2450M + SSD make 花了一个多小时,瓶颈全在 CPU 上,所以慢慢等吧

  1. C:\Qt\4.8.6\bin 下新建 qt.conf 预防修改文件夹名称或移动导致不识别,顺便添加 path
[paths]
Prefix = ../

Configure options for Qt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment