Issue
I am trying to build Qt6 for Windows using x86_64-w64-mingw32 from Linux (Ubuntu 23.10).
My problem is when I am trying to use CMake for the href="https://github.com/qt/qtbase" rel="nofollow noreferrer">QtBase repo, I encounter this error which I can't fix:
CMake Error in CMakeLists.txt:\
IMPORTED_IMPLIB not set for imported target "zstd::libzstd_shared"\
configuration "Release".
The whole stderr
and stdout
of CMake:
% cmake -DQT_ALLOW_SYMLINK_IN_PATHS=1 --toolchain ~/mingw-w64-x86_64.cmake -DQT_HOST_PATH=../build/lib/cmake/Qt6HostInfo -GNinja ..
CMake Warning at CMakeLists.txt:49 (message):
The path "/home/alexsm/LinuxFiles/Workshop/programs/qtbase/build-mingw"
contains symlinks. This is not recommended, and it may lead to unexpected
issues. If you do not have a good reason for enabling
'QT_ALLOW_SYMLINK_IN_PATHS', disable it, and follow one of the following
solutions:
- Map directories using a transparent mechanism such as mount --bind
- Pass the real path of the build directory to CMake, e.g. using
cd $(realpath <path>) before invoking cmake <source_dir>.
Call Stack (most recent call first):
CMakeLists.txt:63 (qt_internal_check_if_path_has_symlinks)
-- The CXX compiler identification is GNU 12.0.0
-- The C compiler identification is GNU 12.0.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/x86_64-w64-mingw32-gcc
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Setting build type to 'Release' as none was specified.
-DCMAKE_C_FLAGS_DEBUG=-g
-DCMAKE_C_FLAGS_RELEASE=-O3 -DNDEBUG
-DCMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG
-DCMAKE_CXX_FLAGS_DEBUG=-g
-DCMAKE_CXX_FLAGS_RELEASE=-O3 -DNDEBUG
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG
-DCMAKE_OBJCOPY=/usr/bin/x86_64-w64-mingw32-objcopy
-DCMAKE_TOOLCHAIN_FILE=/home/alexsm/LinuxFiles/Workshop/projects/auxillary/mingw-w64-x86_64.cmake
-DCMAKE_C_STANDARD=11
-DCMAKE_C_STANDARD_REQUIRED=ON
-DCMAKE_CXX_STANDARD=17
-DCMAKE_CXX_STANDARD_REQUIRED=ON
-DCMAKE_MODULE_PATH:STRING=/home/alexsm/LinuxFiles/Workshop/programs/qtbase/cmake/platforms
-- Configuration summary shown below. It has also been written to /home/alexsm/LinuxFiles/Workshop/programs/qtbase/build-mingw/config.summary
-- Configure with --log-level=STATUS or higher to increase CMake's message verbosity. The log level does not persist across reconfigurations.
-- Configure summary:
Building for: win32-g++ (x86_64, CPU features: )
Compiler: gcc 12.0.0
Build options:
Mode ................................... release
Optimize release build for size ........ no
Fully optimize release builds (-O3) .... no
Building shared libraries .............. yes
Unity Build ............................ no
Relocatable ............................ yes
Using precompiled headers .............. yes
Using Link Time Optimization (LTCG) .... no
Using Intel CET ........................ no
Target compiler supports:
x86 Intrinsics ....................... Basic VAES AVX512VBMI2
Sanitizers:
Addresses ............................ no
Threads .............................. no
Memory ............................... no
Fuzzer (instrumentation only) ........ no
Undefined ............................ no
Build parts ............................ libs
Install examples sources ............... no
App store compliance ................... no
Qt modules and options:
Qt Concurrent .......................... yes
Qt D-Bus ............................... yes
Qt D-Bus directly linked to libdbus .... no
Qt Gui ................................. yes
Qt Network ............................. yes
Qt PrintSupport ........................ yes
Qt Sql ................................. yes
Qt Testlib ............................. yes
Qt Widgets ............................. yes
Qt Xml ................................. yes
Support enabled for:
Using pkg-config ....................... no
Using vcpkg ............................ no
udev ................................... no
OpenSSL ................................ no
Qt directly linked to OpenSSL ........ no
OpenSSL 3.0 ............................ no
Using system zlib ...................... no
Zstandard support ...................... yes
Thread support ......................... yes
Common build options:
Linker can resolve circular dependencies yes
Qt Core:
backtrace .............................. no
DoubleConversion ....................... yes
Using system DoubleConversion ........ no
GLib ................................... no
ICU .................................... no
Using system libb2 ..................... no
Built-in copy of the MIME database ..... yes
Application permissions ................ yes
Tracing backend ........................ <none>
OpenSSL based cryptographic hash ....... no
Logging backends:
journald ............................. no
syslog ............................... no
slog2 ................................ no
PCRE2 .................................. yes
Using system PCRE2 ................... no
Qt Sql:
SQL item models ........................ yes
Qt Network:
getifaddrs() ........................... no
IPv6 ifname ............................ no
libproxy ............................... no
Schannel ............................... yes
DTLS ................................... no
OCSP-stapling .......................... no
SCTP ................................... no
Use system proxies ..................... yes
GSSAPI ................................. no
Brotli Decompression Support ........... no
qIsEffectiveTLD() ...................... yes
Built-in publicsuffix database ....... yes
System publicsuffix database ......... no
Core tools:
Android deployment tool ................ no
macOS deployment tool .................. no
Windows deployment tool ................ no
qmake .................................. yes
Qt Gui:
Accessibility .......................... yes
FreeType ............................... yes
Using system FreeType ................ no
HarfBuzz ............................... yes
Using system HarfBuzz ................ no
Fontconfig ............................. no
Image formats:
GIF .................................. yes
ICO .................................. yes
JPEG ................................. yes
Using system libjpeg ............... no
PNG .................................. yes
Using system libpng ................ no
Text formats:
HtmlParser ........................... yes
CssParser ............................ yes
OdfWriter ............................ yes
MarkdownReader ....................... yes
Using system libmd4c ............... no
MarkdownWriter ....................... yes
EGL .................................... no
OpenVG ................................. no
OpenGL:
Desktop OpenGL ....................... no
Dynamic OpenGL ....................... yes
OpenGL ES 2.0 ........................ no
OpenGL ES 3.0 ........................ no
OpenGL ES 3.1 ........................ no
OpenGL ES 3.2 ........................ no
Vulkan ................................. no
Session Management ..................... yes
Features used by QPA backends:
evdev .................................. no
libinput ............................... no
HiRes wheel support in libinput ........ no
INTEGRITY HID .......................... no
mtdev .................................. no
tslib .................................. no
xkbcommon .............................. no
X11 specific:
XLib ................................. no
XCB Xlib ............................. no
EGL on X11 ........................... no
xkbcommon-x11 ........................ no
xcb-sm ............................... no
QPA backends:
DirectFB ............................... no
EGLFS .................................. no
EGLFS details:
EGLFS OpenWFD ........................ no
EGLFS i.Mx6 .......................... no
EGLFS i.Mx6 Wayland .................. no
EGLFS RCAR ........................... no
EGLFS EGLDevice ...................... no
EGLFS GBM ............................ no
EGLFS VSP2 ........................... no
EGLFS Mali ........................... no
EGLFS Raspberry Pi ................... no
EGLFS X11 ............................ no
LinuxFB ................................ no
VNC .................................... no
VK_KHR_display ......................... no
QNX:
lgmon ................................ no
IMF .................................. no
XCB:
Using system-provided xcb-xinput ..... no
GL integrations:
GLX Plugin ......................... no
XCB GLX .......................... no
EGL-X11 Plugin ..................... no
Windows:
Direct 2D ............................ yes
Direct 2D 1.1 ........................ yes
DirectWrite .......................... yes
DirectWrite 3 ........................ yes
Qt Widgets:
GTK+ ................................... no
Styles ................................. Fusion Windows WindowsVista
Qt Testlib:
Tester for item models ................. yes
Batch tests ............................ no
Qt PrintSupport:
CUPS ................................... no
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... yes
PostgreSQL ............................. no
SQLite ................................. yes
Using system provided SQLite ......... no
Mimer .................................. no
WARNING: QT_ALLOW_SYMLINK_IN_PATHS is enabled. This is not recommended, and it may lead to unexpected issues.
E.g., When building QtWebEngine, enabling this option may result in build issues in certain platforms.
See https://bugreports.qt.io/browse/QTBUG-59769.
WARNING: Basic cpp/winrt support missing. Some features might not be available.
--
Qt is now configured for building. Just run 'cmake --build . --parallel'
Once everything is built, you must run 'cmake --install .'
Qt will be installed into '/usr/local/Qt-6.7.0'
To configure and build other Qt modules, you can use the following convenience script:
/usr/local/Qt-6.7.0/bin/qt-configure-module
If reconfiguration fails for some reason, try removing 'CMakeCache.txt' from the build directory
Alternatively, you can add the --fresh flag to your CMake flags.
-- Configuring done (22.7s)
CMake Error in CMakeLists.txt:
IMPORTED_IMPLIB not set for imported target "zstd::libzstd_shared"
configuration "Release".
CMake Error in CMakeLists.txt:
IMPORTED_IMPLIB not set for imported target "zstd::libzstd_shared"
configuration "Release".
CMake Error in CMakeLists.txt:
IMPORTED_IMPLIB not set for imported target "zstd::libzstd_shared"
configuration "Release".
CMake Error in CMakeLists.txt:
IMPORTED_IMPLIB not set for imported target "zstd::libzstd_shared"
configuration "Release".
CMake Error in CMakeLists.txt:
IMPORTED_IMPLIB not set for imported target "zstd::libzstd_shared"
configuration "Release".
CMake Error in CMakeLists.txt:
IMPORTED_IMPLIB not set for imported target "zstd::libzstd_shared"
configuration "Release".
-- Generating done (0.4s)
CMake Generate step failed. Build files cannot be regenerated correctly.
I tried to build zstd using x86_64-w64-mingw32 and add a parameter for CMake like below:
cmake -DQT_ALLOW_SYMLINK_IN_PATHS=1 --toolchain ~/mingw-w64-x86_64.cmake
-DQT_HOST_PATH=../build/lib/cmake/Qt6HostInfo
-GNinja
-DIMPORTED_IMPLIB=~/zstd/build-mingw/lib/libzstd.dll ..
But I get the same output. I do not know what to do with that (maybe I used the IMPORTED_IMPLIB
arg incorrectly).
The CMake toolchain file I used:
# Sample toolchain file for building for Windows from an Ubuntu Linux system.
#
# Typical usage:
# *) install cross compiler: `sudo apt-get install mingw-w64`
# *) cd build
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/mingw-w64-x86_64.cmake ..
# This is free and unencumbered software released into the public domain.
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
# cross compilers to use for C, C++ and Fortran
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)
# target environment on the build host system
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
# modify default behavior of FIND_XXX() commands
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Solution
Instead of building Qt on your own, you can download a prebuilt one for MinGW from Quasi-MSYS2.
I leave here the reference to the project I am trying to build
Install Quasi-MSYS2 as explained in the readme. Use it to install Qt: make install _qt6-base _qt6-tools
.
Run CMake: cmake -B build
, cmake --build build
.
I'm getting some compilation errors related to incorrect usage of unsinged long
instead of std::size_t
, but that's on you to fix.
Answered By - HolyBlackCat Answer Checked By - Senaida (WPSolving Volunteer)