我按照 MinGW-64-bit 中的说明进行操作,使用选项 A:在 MSYS2-shell 和 MinGW-w64 Win64 Shell 中构建 Qt。
gcc -v 说:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-6.3.0/configure
--build=x86_64-w64-mingw32
--disable-isl-version-check
--disable-libstdcxx-debug
--disable-libstdcxx-pch
--disable-multilib
--disable-nls
--disable-rpath
--disable-symvers
--disable-werror
--disable-win32-registry
--enable-bootstrap
--enable-checking=release
--enable-fully-dynamic-string
--enable-graphite
--enable-languages=c,lto,c++,objc,obj-c++,fortran,ada
--enable-libatomic
--enable-libgomp
--enable-libstdcxx-time=yes
--enable-lto
--enable-shared
--enable-static
--enable-threads=posix
--host=x86_64-w64-mingw32
--libexecdir=/mingw64/lib
--prefix=/mingw64
--target=x86_64-w64-mingw32
--with-arch=x86-64
--with-bugurl=https://sourceforge.net/projects/msys2
--with-gmp=/mingw64
--with-gnu-as
--with-gnu-ld
--with-isl=/mingw64
--with-libiconv
--with-local-prefix=/mingw64/local
--with-mpc=/mingw64
--with-mpfr=/mingw64
--with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include
--with-pkgversion='Rev1, Built by MSYS2 project'
--with-system-zlib
--with-tune=generic
Thread model: posix
gcc version 6.3.0 (Rev1, Built by MSYS2 project)
我下载了源码
git clone https://code.qt.io/qt/qt5.git
cd qt5
perl init-repository
git checkout 5.8
我知道还有其他选择:
- git 克隆 https://github.com/qt/qt5.git
- wget http://download.qt.io/official_releases/qt/5.8/5.8.0/single/qt-everywhere-opensource-src-5.8.0.tar.gz
我在第二个选项(存档)中发现了同样的问题。
安装所有先决条件后,我构建 OpenSSL 和 ICU - 安装在
- /usr/local/openssl
- /usr/local/icu
但是从那里开始的说明不是很清楚。据说使用 windows 命令 shell 来设置一些环境变量。但是后来我使用的是 MSYS2 64 位 shell,所以这些都没有作用。这是我所做的:
export INCLUDE=/usr/local/icu/include:/usr/local/openssl/include
export LIB=/usr/local/icu/lib:/usr/local/openssl/lib
export QMAKESPEC=
export QTDIR=
windows2unix() { local pathPcs=() split pathTmp IFS=\;; read -ra split <<< "$*"; for pathTmp in "${split[@],}"; do pathPcs+=( "/${pathTmp//+([:\\])//}" ); done; echo "${pathPcs[*]}"; }; systemrootP=$(windows2unix "$SYSTEMROOT"); export PATH="$PWD/qtbase/bin:$PWD/gnuwin32/bin:/c/msys64/mingw64/bin:/c/msys64/usr/bin:/c/msys64/usr/local/icu/lib"
export MAKE_COMMAND=
./configure -debug-and-release -opensource -confirm-license -platform win32-g++ -developer-build -c++11 -icu -opengl desktop -openssl -plugin-sql-odbc -nomake examples -nomake tests
配置脚本运行了一段时间,但随后因以下错误而停止:
...
Creating qmake................................................................................................Done.
Info: creating stash file C:\msys64\home\asp\qt5\.qmake.stash
Info: creating super cache file C:\msys64\home\asp\qt5\.qmake.super
ERROR: Unknown command line option '-c++11'.
也许我忘记在某处设置一些标志,但目前我被困在这里。有人知道如何继续吗?
最佳答案
根据 Andrei R. 的评论,我删除了标志 -c++11 并且这个接缝可以解决问题。
This is the Qt Open Source Edition.
You have already accepted the terms of the Open Source license.
Running configuration tests...
Checking for gold linker... no
Checking for valid makespec... yes
Checking for target architecture... x86_64
Checking for SSE2 instructions... yes
Checking for SSE3 instructions... yes
Checking for SSSE3 instructions... yes
Checking for SSE4.1 instructions... yes
Checking for SSE4.2 instructions... yes
Checking for AVX instructions... yes
Checking for bugfree AVX support in compiler... yes
Checking for AVX2 instructions... yes
Checking for AVX512 F instructions... no
Checking for C++14 support... yes
Checking for C++1z support... yes
Checking for compiler defaulting to C++11 or higher... yes
关于c++ - 从源代码构建 Qt 5.8 - 配置 : Unknown command line option '-c++11' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41887821/