Static Qt 6.3.0 RC cross compile on Ubuntu 20.04 for Windows
-
I am trying to upgrade my appveyor script to build Qt 6 (https://ci.appveyor.com/project/squinky86/stigqter/builds/43153896).
The build is failing, so I created a clean Ubuntu 20.04 VM and did the following:
add-apt-repository ppa:rncbc/qt6.3-static-focal apt-get install -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 qtbase6-static
CMake profile at /tmp/profile.cmake:
set(CMAKE_SYSTEM_NAME Windows) set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran) set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /)
OpenSSL is configured and built:
pushd /tmp && wget https://www.openssl.org/source/openssl-3.0.2.tar.gz && tar -zxf openssl-3.0.2.tar.gz && popd pushd /tmp/openssl-3.0.2 && ./Configure mingw64 no-shared no-asm no-err no-tests CROSS_COMPILE=x86_64-w64-mingw32- && make -j3 && popd
Using posix threads:
update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix && update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
Qt 6.3.0 rc goes through the configure process successfully but then fails to build at about the 80% mark (note: if you don't use the cmake update from travis-ci, you can add "-DQT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT=3.16" and get to the same issue):
pushd /tmp/qtbase-everywhere-src-6.3.0-rc && ./configure -prefix /tmp/qt -no-feature-sql-odbc -sql-sqlite -platform linux-g++-64 -qt-host-path /opt/qt6.3-static -xplatform win32-g++ -device-option CROSS_COMPILE=x86_64-w64-mingw32- -release -opengl desktop -mp -static -static-runtime -no-shared -nomake examples -no-icu -optimize-size -openssl-linked -- -DOPENSSL_ROOT_DIR=/tmp/openssl-3.0.2 -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake make #want to build in 1 thread for debugging the build process
Results:
[ 84%] Building CXX object src/plugins/platforms/windows/CMakeFiles/QWindowsIntegrationPlugin.dir/qwindowscontext.cpp.obj /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp: In function ‘int windowDpiAwareness(HWND)’: /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp:155:65: error: ‘GetWindowDpiAwarenessContext’ was not declared in this scope 155 | return static_cast<int>(GetAwarenessFromDpiAwarenessContext(GetWindowDpiAwarenessContext(hwnd))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp:155:29: error: ‘GetAwarenessFromDpiAwarenessContext’ was not declared in this scope 155 | return static_cast<int>(GetAwarenessFromDpiAwarenessContext(GetWindowDpiAwarenessContext(hwnd))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp: In function ‘bool enableNonClientDpiScaling(HWND)’: /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp:163:18: error: ‘EnableNonClientDpiScaling’ was not declared in this scope; did you mean ‘enableNonClientDpiScaling’? 163 | result = EnableNonClientDpiScaling(hwnd) != FALSE; | ^~~~~~~~~~~~~~~~~~~~~~~~~ | enableNonClientDpiScaling /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp: In member function ‘void QWindowsContext::setProcessDpiV2Awareness()’: /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp:422:21: error: ‘SetProcessDpiAwarenessContext’ was not declared in this scope; did you mean ‘SetProcessDpiAwareness’? 422 | const BOOL ok = SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | SetProcessDpiAwareness /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp: In static member function ‘static bool QWindowsContext::systemParametersInfo(unsigned int, unsigned int, void*, unsigned int)’: /tmp/qtbase-everywhere-src-6.3.0-rc/src/plugins/platforms/windows/qwindowscontext.cpp:969:11: error: ‘SystemParametersInfoForDpi’ was not declared in this scope; did you mean ‘SystemParametersInfoW’? 969 | ? SystemParametersInfoForDpi(action, param, out, 0, dpi) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | SystemParametersInfoW make[2]: *** [src/plugins/platforms/windows/CMakeFiles/QWindowsIntegrationPlugin.dir/build.make:168: src/plugins/platforms/windows/CMakeFiles/QWindowsIntegrationPlugin.dir/qwindowscontext.cpp.obj] Error 1 make[1]: *** [CMakeFiles/Makefile2:9183: src/plugins/platforms/windows/CMakeFiles/QWindowsIntegrationPlugin.dir/all] Error 2 make: *** [Makefile:141: all] Error 2
I do not have this issue with Ubuntu 21.10 or 22.04, but Travis-CI's latest supported infrastructure is Ubuntu 20.04. This occurs with ninja or with the makefiles, with cmake update or with vanilla cmake from ubuntu 20.04.
-
Qt 6 requires MingW-8 support in Ubuntu. Adding this PPA (https://launchpad.net/~cybermax-dexter/+archive/ubuntu/mingw-w64-backport) fixed the issue.