c++qtg++qt6c++23

Building Qt6 with g++ 15 and std c++23


I am trying to build Qt 6.8.2 with g++ 15 and std standard c++23. This is my configuration command:

$ export GCC_CC=/usr/bin/gcc-15 \
    GCC_CXX=/usr/bin/g++-15 \
    GCC_CFLAGS="-O2 -fPIC" \
    GCC_CXXFLAGS="-O2 -fPIC -std=c++23" \
    GCC_LDFLAGS=""


$ CC=${GCC_CC} \
CXX=${GCC_CXX} \
CFLAGS="${GCC_CCFLAGS}" \
CXXFLAGS="-O2 -fPIC -fcommon ${GCC_CXXFLAGS}" \
LDFLAGS=${GCC_LDFLAGS} \
/build/deps_sources/qt-everywhere-src-6.8.2/configure FEATURE_clang=OFF -release -opensource -confirm-license \
       -prefix "/build/deps/qt6" \
       -skip qtwebengine \
       -skip qtimageformats \
       -skip qtimageformats \
       -skip qtquicktimeline \
       -skip qtquick3d \
       -skip qtmultimedia \
       -skip qt5compat \
       -skip qtactiveqt \
       -skip qtcharts \
       -skip qtcoap \
       -skip qtdatavis3d \
       -skip qtgraphs \
       -skip qtserialport \
       -skip qtpositioning \
       -skip qtlocation \
       -skip qtdoc \
       -skip qtgrpc \
       -skip qtlottie \
       -skip qtopcua \
       -skip qtquick3dphysics \
       -skip qtquickeffectmaker \
       -skip qtremoteobjects \
       -skip qtscxml \
       -skip qtsensors \
       -skip qtserialbus \
       -skip qtspeech \
       -skip qtvirtualkeyboard \
       -skip qtwebview -- \
       -DCMAKE_CXX_STANDARD=23 \
       -DCMAKE_CXX_STANDARD_REQUIRED=ON \
       -DCMAKE_CXX_EXTENSIONS=OFF \
       -DCMAKE_WARN_DEPRECATED=FALSE \
       -DCMAKE_SUPPRESS_DEVELOPER_WARNINGS=TRUE

For some reason it fails like this:

/usr/bin/g++-15 -DGLSLANG_OSINCLUDE_UNIX -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QASCONST -DQT_NO_QEXCHANGE -DQT_NO_QSNPRINTF -DQT_USE_QSTRINGBUILDER -D_GLIBCXX_ASSERTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/build/qtshadertools/src/glslang/BundledGlslang_Spirv_autogen/include -I/build/deps_sources/qt-everywhere-src-6.8.2/qtshadertools/src/glslang/../3rdparty/glslang -I/build/deps_sources/qt-everywhere-src-6.8.2/qtbase/mkspecs/linux-g++ -I/build/qtbase/include -O2 -fPIC -fcommon -O2 -fPIC -std=c++23 -DNDEBUG -O2 -std=c++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -w -fno-exceptions -U_FORTIFY_SOURCE -Wsuggest-override -fcf-protection=full -D_FORTIFY_SOURCE=3 -ftrivial-auto-var-init=pattern -fstack-protector-strong -fstack-clash-protection -MD -MT qtshadertools/src/glslang/CMakeFiles/BundledGlslang_Spirv.dir/__/3rdparty/glslang/SPIRV/GlslangToSpv.cpp.o -MF qtshadertools/src/glslang/CMakeFiles/BundledGlslang_Spirv.dir/__/3rdparty/glslang/SPIRV/GlslangToSpv.cpp.o.d -o qtshadertools/src/glslang/CMakeFiles/BundledGlslang_Spirv.dir/__/3rdparty/glslang/SPIRV/GlslangToSpv.cpp.o -c /build/deps_sources/qt-everywhere-src-6.8.2/qtshadertools/src/3rdparty/glslang/SPIRV/GlslangToSpv.cpp
96.27 In file included from /build/deps_sources/qt-everywhere-src-6.8.2/qtshadertools/src/3rdparty/glslang/SPIRV/GlslangToSpv.cpp:45:
96.27 /build/deps_sources/qt-everywhere-src-6.8.2/qtshadertools/src/3rdparty/glslang/SPIRV/SpvBuilder.h:247:30: error: 'uint32_t' has not been declared
96.27   247 |     Id makeDebugLexicalBlock(uint32_t line);
96.27       |                              ^~~~~~~~
96.27 /build/deps_sources/qt-everywhere-src-6.8.2/qtshadertools/src/3rdparty/glslang/SPIRV/SpvBuilder.h:64:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
96.27    63 | #include <stack>
96.27   +++ |+#include <cstdint>
96.27    64 | #include <unordered_map>
96.27 /build/deps_sources/qt-everywhere-src-6.8.2/qtshadertools/src/3rdparty/glslang/SPIRV/SpvBuilder.h:444:28: error: 'uint32_t' has not been declared
96.27   444 |     void enterLexicalBlock(uint32_t line);
96.27       |                            ^~~~~~~~
96.27 /build/deps_sources/qt-everywhere-src-6.8.2/qtshadertools/src/3rdparty/glslang/SPIRV/SpvBuilder.h:444:28: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'

Notice that -std=c++17 has been added by the build system behind my back. And indeed if I run the compile command again removing -std=c++17 it compiles without a problem.

Does anyone have a clue why the extra -std=c++17 is being added by the build system, and how to prevent it?


Solution

  • The version of the GLSLang code included in Qt 6.8.2 does not contain the upstream fix for this issue:

    https://github.com/KhronosGroup/glslang/commit/e40c14a3e007fac0e4f2e4164fdf14d1712355bd

    This fix seems to be included in Qt 6.8.3:

    https://github.com/qt/qtshadertools/commit/244f7f62378eeb4a77ec69a71737ffe90c9d787d

    So the solution to your problem is to use Qt 6.8.3.

    Note there's no a priori reason to "build Qt with std=c++23", building your own code with that against a "normal" Qt build will work just fine.


    As @3CEZVQ mentioned in a comment, glslang is an external project used by parts of Qt (namely their shader tools) and it is C++17.