How to correctly build Qt 6.9.1 from source on macOS with imageformat and style plugins?
-
Hello,
After upgrading from Qt 6.8.3 to Qt 6.9.1, I noticed that QGraphicsItem::itemChange has a problem:
- At first, it works normally.
- But after some runtime (> 30 mins), the event always stops firing completely.
- If I restart the application, it works again, but after some runtime, it always stops.
- This looks like a floating bug, but it is reproducible in the sense that it always happens after running for a while.
Note: My application only uses Qt Core + Gui + Widgets (no QML/Quick)
Because of this, I want to build Qt 6.9.1 from source to debug the issue.
However, when I build Qt 6.9.1 from source on macOS, my application cannot load style and image plugins (so the UI has no proper style, and images like PNG/JPEG cannot be loaded).This is the build command I tried:
./configure -feature-imageformat_png -feature-imageformat_jpeg -feature-imageformatplugin -submodules qtimageformats -opensource -confirm-license -debug cmake build . -DCMAKE_CXX_FLAGS="-Wno-error=unused-but-set-variable"
But after building, the folder qt-everywhere-src-6.9.1/qtbase/plugins/imageformats is empty.
My questions:
- What is the correct way to build Qt 6.9.1 from source on macOS so that style and imageformat plugins (qjpeg, qpng, etc.) are available?
- Is there a recommended build configuration for debugging Qt itself on macOS?
Thank you!
-
Please start over with a clean source dir and an out of source build. Also post the output of the configure call.
-
Please start over with a clean source dir and an out of source build. Also post the output of the configure call.
@Christian-Ehrlicher Thank you for your reply.
I have downloaded a fresh copy of the Qt 6.9.1 sources and tried to run ./configure again, but the output is only the following:
./configure -feature-imageformat_png -feature-imageformat_jpeg -feature-imageformatplugin -submodules qtimageformats -opensource -confirm-license -debug + /qt-everywhere-src-6.9.2/qtbase/configure -top-level -feature-imageformat_png -feature-imageformat_jpeg -feature-imageformatplugin -opensource -confirm-license -debug -submodules qtimageformats -- -DBUILD_qtimageformats=ON '/usr/local/bin/cmake' '-DQT_BUILD_SUBMODULES=qtimageformats' '-DBUILD_qtimageformats=ON' '-DQT_INTERNAL_CALLED_FROM_CONFIGURE:BOOL=TRUE' '-DFEATURE_imageformat_png=ON' '-DFEATURE_imageformat_jpeg=ON' '-DFEATURE_imageformatplugin=ON' '-DCMAKE_BUILD_TYPE=Debug' '-G' 'Ninja' '/qt-everywhere-src-6.9.2' -- The CXX compiler identification is AppleClang 17.0.0.17000013 -- The C compiler identification is AppleClang 17.0.0.17000013 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - 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/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- The ASM compiler identification is AppleClang -- Found assembler: /usr/bin/cc -- Checking dependencies of submodule 'qtbase' -- Checking dependencies of submodule 'qtimageformats' -- Configuring submodule 'qtbase' -- [QtBase] CMAKE_BUILD_TYPE was already explicitly set to: 'Debug' -- Configuring submodule 'qtimageformats' -- Configuration summary has been written to /qt-everywhere-src-6.9.2/config.summary -- 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.9.2' To configure and build other Qt modules, you can use the following convenience script: /usr/local/Qt-6.9.2/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 (50.7s) -- Generating done (1.8s) -- Build files have been written to: /qt-everywhere-src-6.9.2
It seems my ./configure command is not correct.
Could you please provide me with an example of the correct configure command line for building Qt 6.9.1 on macOS (with imageformat and style plugins enabled)?Thanks in advance!
-
It does not appear you are doing an out-of-source build, which is very important. And the flags seems off - were they suggested by an AI assistant?
Carefully read the instructions for building on macOS: https://doc.qt.io/qt-6/macos-building.html
Also note that unless you are doing a developer's build from Git, you need to install your build results to the configured prefix to be able to use the Qt you built in an application.
-
It does not appear you are doing an out-of-source build, which is very important. And the flags seems off - were they suggested by an AI assistant?
Carefully read the instructions for building on macOS: https://doc.qt.io/qt-6/macos-building.html
Also note that unless you are doing a developer's build from Git, you need to install your build results to the configured prefix to be able to use the Qt you built in an application.
@IgKh Thank you for your feedback.
I followed the instructions from the README that comes with the source package, but after building, I still cannot get any style or image plugins loaded (also, I specifically want a debug build).
The official Qt documentation also does not provide a clear description of how to specify configuration options in detail. I did try to consult an AI assistant, but as you guessed, it did not really understand Qtโs build system.
The options I used:
-feature-imageformat_png, -feature-imageformatplugin, -submodules qtimageformats
were based on the output of./configure -list-features
and./configure --help
, not AI. However, these flags also donโt seem to work as expected.So my question is:
๐ Could you please provide me with a typical example configure (or cmake) command for building Qt Core + Gui + Widgets (with debug mode) on macOS?That would help me a lot to get started in the right direction.
-
Hi,
Based on experience as well as the macOS Documentationmkdir -p ~/dev/Qt-build cd ~/dev/Qt-build /path/to/QtSources/configure -submodules qtbase qtimageformats -debug cmake --build . --parallel cmake --install .
If you want to debug or try some things, you can do a developer build. That way you don't need to re-install Qt every time you try something. Don't use a developer build for building a production version of your application.
I also would not recommend altering the PATH environment variable. Just use the full path to the tools you want to use so you ensure you are using the exact version of Qt you actually want to use.
-
What @SGaist said, plus add a
-prefix
flag toconfigure
with a path to somewhere in your User directory, so you won't install your build system-wide.Specifically, after configuring look at the file it tells you (
config.summary
). It should have a section like:Qt Gui: Accessibility .......................... yes Emoji Segmenter ........................ 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
If it says "yes" for the image formats you care about, you are good to go - but again, you won't see the plugin files until you install the build into the prefix you set.
-
I started over as suggested. I placed the Qt 6.9.2 source folder under my User directory on another macOS. Then I ran the following two commands:
./configure -submodules qtbase,qtimageformats -debug -prefix ../qt6-sdk cmake build . -DCMAKE_CXX_FLAGS="-Wno-error=unused-but-set-variable"
But the output is only:
./configure -submodules qtbase,qtimageformats -debug -prefix ../qt6-sdk + /Users/kevin/Projects/qt-everywhere-src-6.9.2/qtbase/configure -top-level -debug -prefix ../qt6-sdk -submodules qtbase,qtimageformats -- -DBUILD_qtbase=ON -DBUILD_qtimageformats=ON '/usr/local/bin/cmake' '-DQT_BUILD_SUBMODULES=qtbase;qtimageformats' '-DBUILD_qtbase=ON' '-DBUILD_qtimageformats=ON' '-DQT_INTERNAL_CALLED_FROM_CONFIGURE:BOOL=TRUE' '-DCMAKE_INSTALL_PREFIX=../qt6-sdk' '-DCMAKE_BUILD_TYPE=Debug' '-G' 'Ninja' '/Users/kevin/Projects/qt-everywhere-src-6.9.2' -- The CXX compiler identification is AppleClang 17.0.0.17000013 -- The C compiler identification is AppleClang 17.0.0.17000013 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - 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/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- The ASM compiler identification is AppleClang -- Found assembler: /usr/bin/cc -- Checking dependencies of submodule 'qtbase' -- Checking dependencies of submodule 'qtimageformats' -- Configuring submodule 'qtbase' -- [QtBase] CMAKE_BUILD_TYPE was already explicitly set to: 'Debug' -- Configuring submodule 'qtimageformats' -- Configuration summary has been written to /Users/kevin/Projects/qt-everywhere-src-6.9.2/config.summary -- 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 '/Users/kevin/Projects/qt6-sdk' To configure and build other Qt modules, you can use the following convenience script: /Users/kevin/Projects/qt6-sdk/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 (49.2s) -- Generating done (1.9s) -- Build files have been written to: /Users/kevin/Projects/qt-everywhere-src-6.9.2
cmake build . -DCMAKE_CXX_FLAGS="-Wno-error=unused-but-set-variable" -- Checking dependencies of submodule 'qtbase' -- Checking dependencies of submodule 'qtimageformats' -- Configuring submodule 'qtbase' -- [QtBase] CMAKE_BUILD_TYPE was already explicitly set to: 'Debug' -- Configuring submodule 'qtimageformats' -- Configuration summary has been written to /Users/kevin/Projects/qt-everywhere-src-6.9.2/config.summary -- Configuring done (19.7s) -- Generating done (1.8s) -- Build files have been written to: /Users/kevin/Projects/qt-everywhere-src-6.9.2
My config.summary looks like this:
Building for: macx-clang (x86_64, CPU features: cx16 sse3 ssse3 sse4.1) Compiler: clang (Apple) 17.0.0.17000013 Build options: Mode ................................... debug Fully optimize release builds (-O3) .... no Building shared libraries (alias of BUILD_SHARED_LIBS) yes Using ccache ........................... no Unity Build ............................ no Relocatable ............................ yes Using precompiled headers .............. yes Using Link Time Optimization (LTCG) .... no Using Intel Control-flow Enforcement Technology (CET) yes Using Glibc function fortification ..... no Using -ftrivial-auto-var-init=pattern .. yes Using -fstack-protector-strong ......... yes Using -fstack-clash-protection ......... no Using libstdc++ assertions ............. no Using libc++ hardening ................. yes Using -z relro -z now when linking ..... 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 tools 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 1.1 ............................ no OpenSSL 3.0 ............................ no Using system zlib ...................... yes Zstandard support ...................... no Thread support ......................... yes Common build options: Linker can resolve circular dependencies yes Qt Core: backtrace .............................. yes C++23 <stacktrace> ..................... no DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no ICU .................................... no std::chrono::tzdb QTZ backend .......... no Using system libb2 ..................... no Built-in copy of the MIME database ..... yes Application permissions ................ yes Defaulting legacy IPC to POSIX ......... no 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() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no SecureTransport ........................ yes DTLS ................................... no OCSP-stapling .......................... no SCTP ................................... no Use system proxies ..................... yes GSSAPI ................................. yes Brotli Decompression Support ........... no qIsEffectiveTLD() ...................... yes Built-in publicsuffix database ....... yes System publicsuffix database ......... no Core tools: Android deployment tool ................ yes macOS deployment tool .................. yes Windows deployment tool ................ no qmake .................................. yes Qt Gui: Accessibility .......................... yes Emoji Segmenter ........................ 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 ....................... yes OpenGL ES 2.0 ........................ no OpenGL ES 3.0 ........................ no OpenGL ES 3.1 ........................ no OpenGL ES 3.2 ........................ no Vulkan ................................. no Metal .................................. yes QGraphicsFrameCapture .................. yes Session Management ..................... yes Multi-threaded image and painting helpers 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 vxworksevdev ........................... 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 ............................ no Direct 2D 1.1 ........................ no DirectWrite .......................... no DirectWrite 3 ........................ no DirectWrite COLRv1 Support ........... no Qt Widgets: GTK+ ................................... no Styles ................................. Fusion macOS Windows Qt Testlib: Tester for item models ................. yes Batch tests ............................ no Qt PrintSupport: CUPS ................................... yes Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite ................................. yes Using system provided SQLite ......... no Mimer .................................. no Further Image Formats: JasPer ................................. no MNG .................................... no TIFF ................................... yes Using system libtiff ................. no WEBP ................................... yes Using system libwebp ................. no
However, no files are actually built afterwards.
Do you know what I might be missing here? -
You did not call
cmake --install .
after the build.On a side note, do you realize that several people wrote that you should do out of source builds but you persist not to follow that suggestion ?
-
You did not call
cmake --install .
after the build.On a side note, do you realize that several people wrote that you should do out of source builds but you persist not to follow that suggestion ?
@SGaist I also tried running
cmake --install .
but it does not work. The output is:cmake --install . -- Install configuration: "Debug" -- Installing: /Users/kevin/Projects/qt6-sdk/lib/cmake/Qt6BuildInternals/Qt6BuildInternalsConfig.cmake -- Installing: /Users/kevin/Projects/qt6-sdk/lib/cmake/Qt6BuildInternals/Qt6BuildInternalsConfigVersion.cmake -- Installing: /Users/kevin/Projects/qt6-sdk/lib/cmake/Qt6BuildInternals/Qt6BuildInternalsConfigVersionImpl.cmake -- Installing: /Users/kevin/Projects/qt6-sdk/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake -- Installing: /Users/kevin/Projects/qt6-sdk/lib/cmake/Qt6BuildInternals/QtStandaloneTestTemplateProject -- Installing: /Users/kevin/Projects/qt6-sdk/lib/cmake/Qt6BuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt -- Installing: /Users/kevin/Projects/qt6-sdk/lib/cmake/Qt6BuildInternals/QtStandaloneTestTemplateProject/Main.cmake -- Installing: /Users/kevin/Projects/qt6-sdk/lib/cmake/Qt6/qt.toolchain.cmake -- Installing: /Users/kevin/Projects/qt6-sdk/mkspecs/qconfig.pri CMake Error at qtbase/cmake_install.cmake:62 (file): file INSTALL cannot find "/Users/kevin/Projects/qt-everywhere-src-6.9.2/qtbase/mkspecs/qmodule.pri": No such file or directory. Call Stack (most recent call first): cmake_install.cmake:42 (include)
From the output of
cmake --build .
above, you can also see that no files are actually built at all. -
If you want help use an out of source build with a clean build directory...
-
If you want help use an out of source build with a clean build directory...
@Christian-Ehrlicher I deleted the old qt-everywhere-src-6.9.2 folder, extracted a fresh copy, and the qt6-sdk folder is also empty.
I donโt understand why it is not working anymore.
-
Please: Out of source build
-
Thanks for your help, I finally managed to build Qt 6.9.2 successfully. ๐
The problem was that I was trying to build inside the source folder instead of doing an out-of-source build. -
-
Thanks for your help, I finally managed to build Qt 6.9.2 successfully. ๐
The problem was that I was trying to build inside the source folder instead of doing an out-of-source build.@Kevin-Hoang said in How to correctly build Qt 6.9.1 from source on macOS with imageformat and style plugins?:
Thanks for your help, I finally managed to build Qt 6.9.2 successfully. ๐
The problem was that I was trying to build inside the source folder instead of doing an out-of-source build.Please, next time listen to people answering you. We told you five times to do an out of source build beside the documentation also showing that.
-
@Kevin-Hoang said in How to correctly build Qt 6.9.1 from source on macOS with imageformat and style plugins?:
Thanks for your help, I finally managed to build Qt 6.9.2 successfully. ๐
The problem was that I was trying to build inside the source folder instead of doing an out-of-source build.Please, next time listen to people answering you. We told you five times to do an out of source build beside the documentation also showing that.
@SGaist Sorry about that ๐. To be honest, I was busy with another project, so I wasnโt fully focused, and since this wasnโt my main target, I overlooked the instructions. ๐
Now itโs clear to me, and I managed to build successfully. Thanks again for pointing me in the right direction!