使用MSYS2 / MinGW 64构建Qt源 - 未找到ICU标头

时间:2017-01-27 11:33:15

标签: qt icu msys mingw-w64

我按照MinGW-64-bit的说明,使用选项A:在MSYS2-shell&中构建Qt。 MinGW-w64 Win64 Shell。

我下载了源代码

git clone https://code.qt.io/qt/qt5.git
cd qt5
perl init-repository
git checkout 5.8

安装所有先决条件后,我构建了OpenSSL和ICU - 安装在

  • 的/ usr /本地/ OpenSSL的
  • 的/ usr /本地/ ICU

但从那里开始,指示并不那么明确。它声明使用windows命令shell来设置一些环境变量。但后来我使用的是MSYS2 64 Bit 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=

mkdir qt-build
cd qt-build

../qt5/configure -prefix /opt/qt -debug-and-release -opensource -confirm-license -platform win32-g++ -developer-build -icu -I /usr/local/icu/include -opengl desktop -openssl -plugin-sql-odbc -nomake examples -nomake tests

configure脚本因以下错误而停止:

ERROR: Feature 'icu' was enabled, but the pre-condition 'libs.icu' failed.

在Qt的config.log中,我发现:

looking for library icu
Trying source 0 (type inline) of library icu ...
 => source failed condition 'config.win32 && !features.shared'.
Trying source 1 (type inline) of library icu ...
+ cd C:\msys64\home\asp\qt-build\qtbase\config.tests\unix\icu && C:\msys64\home\asp\qt-build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console" "LIBS += -licuin -licuuc -licudt" C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu
+ cd C:\msys64\home\asp\qt-build\qtbase\config.tests\unix\icu && set MAKEFLAGS=& C:/msys64/usr/bin/make
> g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -IC:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu -I. -IC:/msys64/home/asp/qt5/qtbase/mkspecs/win32-g++  -o icu.o C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu/icu.cpp
> C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu/icu.cpp:40:28: fatal error: unicode/utypes.h: No such file or directory
>  #include <unicode/utypes.h>
>                             ^
> compilation terminated.
> make: *** [Makefile:155: icu.o] Fehler 1
 => source failed verification.
Trying source 2 (type inline) of library icu ...
 => source failed condition '!config.win32'.
test config.corelib.libraries.icu FAILED

为什么脚本找不到包含?我将它们设置为

  • 参数&#39; -I / usr / local / icu / include&#39;
  • export INCLUDE = / usr / local / icu / include:/ usr / local / openssl / include

我也试过

  • 参数&#39; -I / C / msys64 / usr / local / icu / include&#39;
  • export INCLUDE = / C / msys64 / usr / local / icu / include:/ C / msys64 / usr / local / openssl / include

是否有另一种可能性为编译器提供正确的INCLUDE路径?

1 个答案:

答案 0 :(得分:1)

最后我解决了这个问题!

我删除了完整的qt5文件夹并从头开始。然后我收到以下错误:

looking for library icu
Trying source 0 (type inline) of library icu ...
  => source failed condition 'config.win32 && !features.shared'.
Trying source 1 (type inline) of library icu ...
+ cd C:\msys64\home\asp\qt-build\qtbase\config.tests\unix\icu && C:\msys64\home\asp\qt-build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console" "INCLUDEPATH += C:/msys64/usr/local/icu/include" "LIBS += -licuin -licuuc -licudt" C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu
+ cd C:\msys64\home\asp\qt-build\qtbase\config.tests\unix\icu && set MAKEFLAGS=& C:/msys64/usr/bin/make clean && set MAKEFLAGS=& C:/msys64/usr/bin/make
> rm -f icu.o
> g++ -c -pipe -fno-keep-inline-dllexport -g -Wall -Wextra -fexceptions -mthreads -DUNICODE -IC:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu -I. -IC:/msys64/usr/local/icu/include -IC:/msys64/home/asp/qt5/qtbase/mkspecs/win32-g++  -o icu.o C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu/icu.cpp
> g++ -Wl,-subsystem,console -mthreads -o icu.exe icu.o  -licuin -licuuc -licudt 
> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -licuin
> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -licuuc
> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -licudt
> collect2.exe: error: ld returned 1 exit status
> make: *** [Makefile:62: icu.exe] Fehler 1
 => source failed verification.
Trying source 2 (type inline) of library icu ...
  => source failed condition '!config.win32'.
test config.corelib.libraries.icu FAILED

这次可以找到标题!但现在ICU lib无法链接。所以我添加了'-L / C / msys64 / usr / local / icu / lib'并再次尝试:

../qt5/configure -prefix /opt/qt -debug-and-release -opensource -confirm-license -platform win32-g++ -developer-build -icu -I /C/msys64/usr/local/icu/include -L /C/msys64/usr/local/icu/lib -opengl desktop -openssl -plugin-sql-odbc -nomake examples -nomake tests

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into 'C:\msys64\opt\qt'