Is _GLIBCXX_USE_CXX11_ABI=0 defined in pre-build versions of Qt?
-
Gcc ABI was significantly changed between 4.x and 5.x. If you try to link application with third-party library that was compiled with an older version of GCC then you get linker errors about undefined references to symbols that involve types in the std::__cxx11 namespace. The problem is related to https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
But the same Qt binary distribution for Linux links correctly for gcc 5.x and gcc 4.x.
What was done to get this result? How the problem of different gcc ABI is resolved? Is _GLIBCXX_USE_CXX11_ABI=0 defined for Qt pre-build version that is available to download?
-
@sierdzio said in Is _GLIBCXX_USE_CXX11_ABI=0 defined in pre-build versions of Qt?:
Please ask on Interest mailing list, many developers who write Qt are present there.
I have got answer from Interest mailing list.
Summary:Q: Why the same Qt binaries may be used with different compilers (gcc 4.x, gcc 5.x) and other libraries cannot be used?
A: GCC ABI was changed for standard library (https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html ). Qt does not depend on standard library. If other library depends on standard library then it will link with errors. Inline methods (like QString::toStdString, QVector::toStdVector, etc...) are fine because they are compiled with the same C++ ABI as used in the applicationQ: Is it possible for GCC 5.x to link with the library compiled by GCC 4.x?
A: Yes. The old GCC ABI is still supported and can be used by defining the macro _GLIBCXX_USE_CXX11_ABI to 0 before including any C++ standard library headers (https://gcc.gnu.org/gcc-5/changes.html#libstdcxx ). -
@blex said in Is _GLIBCXX_USE_CXX11_ABI=0 defined in pre-build versions of Qt?:
I have got answer from Interest mailing list.
Thank you for sharing it here as well!
-
Came across the same issue today with Qt 6.7.2 on macOS Ventura when building my app with GCC 14.2.0 (in C++23 mode). That is, because Qt was built with Apple Clang (14.0.0) which does not set
_GLIBCXX_USE_CXX11_ABI=1
.Inline methods (like QString::toStdString, QVector::toStdVector, etc...) are fine because they are compiled with the same C++ ABI as used in the application.
That does no longer seems to be the case, because
QByteArray::toStdString()
is not defined in its header.Just for reference, I get the following linker errors:
Undefined symbols for architecture x86_64: "QByteArray::toStdString[abi:cxx11]() const", referenced from: QString::toStdString[abi:cxx11]() const in main.cpp.o ld: symbol(s) not found for architecture x86_64