Skip to content

Getting your 3D Ready for Qt 6 compiling Qt 3D for Qt 6 and up

As was previously discussed, since the 6.0.0 release of Qt, Qt 3D no longer ships as a pre-compiled module. If you need to use it on your projects, try out the new features, or just see your existing application is ready for the next chapter of Qt’s life, you need to compile Qt 3D from source.

In order to do this, you can do it the traditional way ([cq]make ...; make; make install) or use the Conan-based system that is being pioneered with the latest version of the MaintenanceTool.

Using Conan

The latest version of the MaintenanceTool (from the unified installers) will optionally install several things:

  • Conan, a package manager which can build C++ libraries and handle the dependencies
  • CMake, the meta-build system, which is required for Qt 6
  • Ninja, the lighting fast replacement for make and nmake

Additionally, you will need to select Qt 3D in the Additional libraries section so that the source code is available.

As mentioned above, these are optional. You need to find them and enable them in the MaintenanceTool’s UI.

 

Conan, being a package manager, is designed to handle all dependencies to make it easy to build libraries and applications. However, the way this is setup in the current packages installed by the MaintenanceTool is not complete.

Additional things you need for Conan

In particular, you need two other things:

  • You need to select the Qt Shader Tools module in the MaintenanceTool, if you intend to use the new RHI-based backend for Qt 3D. Without it, Qt 3D will build fine but only the original (and more feature rich) backend will be available.
  • Since Qt 3D is a Qt module, it has many of the similar requirements you need when building Qt itself. At the very least, you need a perl interpreter, so that the module header files can be generated. A full list of requirements for the various platforms is available here.

Once you have all the required bits, it’s time to open a console and run Conan. The process is platform-specific, as each platform has it’s own Conan profile. A complete example is available on the Qt wiki, but this is how it works on my mac where the Qt SDK is installed in /Users/Shared/Qt:

conan install qt3d/6.0.0@qt/final --build=missing -s build_type=Release -g cmake_paths -g=cmake -g deploy --profile=/Users/Shared/Qt/Tools/Conan/profiles/qt-6.0.0-macx-clang

and wait…it takes a while to build Qt 3D.

Notes:

  • conan, cmake and ninja need to be in your path. In particular, make sure the Qt provided version of Conan is found first, because…
  • the MaintenanceTool installs a custom version of Conan and write config files in the $HOME/.conan folder. This means, at least on multi-user systems, Conan will only properly work for the user who installed the Qt SDK, and that version is found before any platform-provided version.

 

Using QMake or CMake

Using the MaintenanceTool and Conan makes it easy to get the source and the required dependencies for building Qt 3D. As we saw in the aforementioned, there are still some rough edges. So, in particular, if you are familiar with building Qt modules already, you can just use the “old way”, i.e., download the source and use QMake, or now, CMake.

The packages for the released versions of Qt 3D (and other Additional modules) are available here.

QMake

Once extracted, you can do a shadow build of Qt 3D pretty easily (this has the same build requirements as above though, QtShaderTools module and perl interpreter).

tar zxf qt3d-everywhere-src-6.0.0.tar.xz
cd qt3d-everywhere-src-6.0.0
mkdir build
cd build
/Users/Shared/Qt/6.0.0/clang_64/bin/qmake ..
make
make install

And, again, wait 🙂.

CMake

The process is similar if you want to use CMake instead. In the build folder, do:

/Users/Shared/Qt/6.0.0/clang_64/bin/qt-cmake -G Ninja ..
ninja
ninja install

Once done, your applications should be able to find the Qt 3D modules.

You can optionally build the documentation using the docs target (but this will not be installed; you will need to register it with Creator and/or QtAssistant for it to appear).

Note:

Qt 3D will likely preserve the dual QMake/CMake build system for a while still.

Conclusion

As you see, building Qt 3D involves a bit more work than it did before. Fortunately, it needs to be done only once for each release. Going forward, we will be able to release Qt 3D on a different cycle from the rest of Qt and, as a result, introduce features and bug fixes more frequently. Please do not hesitate to get in touch with us or the Qt build system team if you have questions regarding this new setup.

 

KDAB provides a number of services around Qt 3D, including mentoring your team and embedding Qt 3D code into your application, among others. You can find out more about these services here.

 

About KDAB

If you like this article and want to read similar material, consider subscribing via our RSS feed.

Subscribe to KDAB TV for similar informative short video content.

KDAB provides market leading software consulting and development services and training in Qt, C++ and 3D/OpenGL. Contact us.

Categories: KDAB Blogs / KDAB on Qt / Qt / Qt3D / QtDevelopment / Technical

Tags: / / / / /

5 thoughts on “Getting your 3D Ready for Qt 6”

  1. Could some thought be given to vcpkg as well? We went with that instead of Conan – seems like less hassle not to deal with Python, and the overall ecosystem is clearer to work with.

  2. How can I compile Qt3D for Windows? I am always getting errors when using qmake:

    C:\Qt\AdditionalLibraries\Qt\qt3d-6.1.0\Src\src\core\qabstractfrontendnodemanager_p.h(54): fatal error C1083: Cannot open include file: ‘Qt3DCore/qt3dcore_global.h’: No such file or directory
    Generating Code…
    NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\cl.EXE”‘ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\nmake.exe”‘ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.

    1. sounds like the module headers were not generated. Do you have perl installed and in your path?

  3. Hi !

    we are currently doing our migration to Qt6 and after compiling the Qt3d package thanks to conan we encounter some problems on the qml side :

    module “QtQuick.Scene3D” plugin “qtquickscene3dplugin” not found
    import QtQuick.Scene3D 2.15

    it is quite weird as we added the qml import path of the compiled package :
    QQuickView view;
    view.engine()->addImportPath(“qrc:/frontend/imports”);

    view.engine()->addImportPath(“../common/libs/qt3dpackages/debug_mode/qml”);

    We also spotted that the plugin is compiled statically using conan, is there a way it can be the issue ? indeed the qml plugins of our qt6.0.3 repo are .dll

    BR,

Leave a Reply

Your email address will not be published. Required fields are marked *