Error building kio

I’m trying to build gwenview using kde-builder. Everything is just fine until it tries to compile the kio module. I haven’t touched any file and, just as a reference, a few days ago I built kcalc following the tutorial (but I don’t know if kcalc depends on kio indirectly).

Here is the part of the log where the error is described:

/home/pe/kde/src/kio/src/core/directorysizejob.cpp:136:15:   required from here
**/usr/include/c++/11/bits/stl_algobase.h:1162:29: error: no match for ‘operator==’ (operand types are ‘const KIO::UDSEntry’ and ‘const KIO::UDSEntry’)**
 1162 |             if (!(*__first1 == *__first2))
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~
In file included from /home/pe/kde/qt/include/QtCore/qtypeinfo.h:12,
                 from /home/pe/kde/qt/include/QtCore/qglobal.h:47,
                 from /home/pe/kde/qt/include/QtCore/qnamespace.h:12,
                 from /home/pe/kde/qt/include/QtCore/qobjectdefs.h:12,
                 from /home/pe/kde/qt/include/QtCore/qobject.h:10,
                 from /home/pe/kde/qt/include/QtCore/QObject:1,
                 from /home/pe/kde/usr/include/KF6/KCoreAddons/kjob.h:14,
                 from /home/pe/kde/usr/include/KF6/KCoreAddons/kcompositejob.h:13,
                 from /home/pe/kde/usr/include/KF6/KCoreAddons/KCompositeJob:1,
                 from /home/pe/kde/src/kio/src/core/job_base.h:12,
                 from /home/pe/kde/src/kio/src/core/directorysizejob.h:11,
                 from /home/pe/kde/src/kio/src/core/directorysizejob.cpp:8:

I see the same error repeated for some other files in that module. Apparently, the operator== is not defined for some class, but I really doubt that is the underlying problem. Any idea what the problem is and how to solve it?

I finally solved it.

The solution was changing the g++ version used. My system had g++11 and g++12, and g++11 was the default. Apparently, kio must be compiled using a version >= g++12.

To set a compiler as a default in a debian-derived system, use update-alternatives:

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100

I don’t know if it’s necessary but I did the same for gcc.

I think it would be nice to get an error before compilation saying that your system doesn’t have the required compiler version. Is this possible?