Build Qt5.15.11 for macOS, Including Qt Webengine as Universal Binary

To address a common suggestion upfront, using Homebrew or macports to install Qt isn't viable in this case, as it doesn't provide a universal build of Qt. For those aiming to work with an open-source version, you have to go the path of pain. Let's try to make it less harder.

Dancing program,mer in front of a macbook and Qt cup

Build Qt Lib

This process will be carried out in one step. In the tutorials for Windows and Linux, we'll construct the Qt Library while bypassing the Qt Webengine in the first step. Assembling the primary library is straightforward, especially when contrasted with the complexities of QWebengine. Additionally, this approach allows for the utilization of all available CPU cores without any worries.

But for some mysterious reasons this is not possible with macOS. The second step will throw errors mostly after 90%. Let's do it in one step.

Requirements for Qt-Lib

  • macOS 13 (Ventura). Currently, it this procedure will not work with macOS 14 and Xcode 15. Sonoma requires Xcode 15. If you find a way to include QWebengine with Xcode 15, contact me.
  • Xcode 14.01.

    Don't fool around and try any newer Xcode. You will waste your time like me. The reason seems to bee that this is the last Xcode version which includes macOS 12 SDK. With newer version of Xcode, you have to deal with SDK 13. You will be able after applying some patches to build the Qt lib, but Qt Webengine build will fail and fail.

    This is also the other reason not install macOS Sonoma. As indicated above, Xcode 14.01 will not work with macOS 14.

  • Qt5.15.11 Source code.
    tar xvf qt-everywhere-opensource-src-5.15.11.tar.xz
    I would suggest creating a Qt and moving the extracted as Src
    mkdir -p Qt/5.15.11/
    mv qt-everywhere-opensource-src-5.15.11 Qt/5.15.11/Src

Requirements and Preparatory her Annoyance: QWebengine

The frustration of dealing with this software that repeatedly fails to compile can be likened to the relentless demands of an attention-seeking child. Each failed attempt at compiling is a cry for attention, a signal that something is amiss and requires immediate care and intervention. Welcome to the annoying world of Qt's Webengine.

  • You need to install some software. I prefer macports because it installs in /opt and is more independent of macOS libs. Which makes it slower to install but more stable. You can also use Homebrew.
    sudo port install python27 gperf bison flex nodejs pkg-config
    If you have python3 already install, do not forget to select python2 before compiling.
    port select --list python
    to see which versions are install and then probably
    sudo port select --set python python27

Build Steps for Qt-Lib

  1. Open a Terminal, create a shadow directory and enter it.

    Utilizing a shadow build directory is highly beneficial when constructing Qt software or C++ applications. This method, which maintains a separation between source code and build artifacts, facilitates multiple build configurations, eases the cleanup process, and offers several other advantages.

    mkdir build_qt
    cd build_qt
  2. Set the path to the correct compiler if you have multiple versions of Xcode installed. In my case, I renamed the Xcode folder in Applications to Xcode_14_01 and exported the DEVELOPER_DIR environment variable.
    export DEVELOPER_DIR=/Applications/
  3. Call the configure script in the directory of the source.
    $QT_SRC/configure QMAKE_APPLE_DEVICE_ARCHS="x86_64 arm64" \
        -release -optimize-size \
    	-opensource -confirm-license -nomake tests -nomake examples \
        -no-openssl -securetransport \
    	-webengine-proprietary-codecs \
        -prefix path/to/qt/5.15.11/clang_64 \
        -skip qttranslations \
    	-skip qtserialport \
    	-skip qtwayland \
    	-skip qtdoc \
    	-skip qtpurchasing \
    	-skip qtvirtualkeyboard \
    	-skip qtspeech


    • QMAKE_APPLE_DEVICE_ARCHS="x86_64 arm64" set the universal build for Intel/AMD and arm CPUs.
    • -optimize-size creates smaller size binaries. It seems to be a linker bug, “Unable to insert branch island. No insertion point available for architecture armv8” in ld which cannot link files bigger than 40MB in QWebengine. As it is frustrating when a build fails in the linking process after hours of compiling.
    • Wayland, ActiveQt, SerialPort, and more are not necessary for garlic-player.
    • -no-openssl -securetransport There is no need to use openssl as macOS uses its own SSL lib.
    • The parameter -release will build the release version. If you want to debug Qt, use -debug.
    • -webengine-proprietary-codecs

      This option activates compatibility for specialized media codecs not present in the basic build, including AAC, H.264, and MP3. It expands the variety of media formats that can be played in applications utilizing Qt Webengine. This is particularly useful for ensuring compatibility with specific web content that relies on these codecs.

    • -prefix path/to/qt/5.15.11/clang_64 defines that make install will install created Qt binaries on this directory.

    This will build qmake and some other stuff.

    In case of errors or something is missing, you will get a more or less detailed notice. If everything is fine, continue to the next step.

  4. Call make with multicore support for M1. Use more if you have more cores and space. With 16 GB Ram, it appears to be safe to use all available cores.
    make -j8

    Have some patience. The build needs more than 2,5 hours on my M1 Pro MacBook. Btw.: That is your chance to hear the fan.

  5. Install compiled lib to -prefix directory.
    make install
    This will also take some minutes.

Share Your Thoughts

Your input is significant. Should you have any thoughts, ideas, or suggestions for improvement, please feel free to get in touch. You can share your feedback by emailing me or connecting on LinkedIn (find the links in the footer). Every message, whether it's a word of thanks, a query, or a recommendation for enhancement, plays a crucial role in determining the quality and trajectory of our upcoming content.

Thank you for following along, and happy coding!