Important: Please read the Qt Code of Conduct -

Is there a way to make a library that can be used with other compilers (C++) in QT

  • I mean of course that the header file can't include QT types. I have tried to do this and it didn't work.

  • Moderators

    C++ has no defined ABI, so there is no way to make a C++ library work across two incompatible compilers, because of different export name mangling.

    C on the other hand has such ABI, so you can make C libraries that work across conformant compilers and you can export C interface to your otherwise C++ library using extern "C".

    You are restricted to exporting only C types this way though, so no classes etc.

  • Moderators

    Although @Chris is very much correct, as is his usual style, I hope you are not left with the impression that you can't use C++ at all inside the library, though. His point concerns the symbols alone. You could use as much C++ as you want inside (i.e in the private part/implementation(s)) the library, you just need to export a C interface for it to be compatible between different compilers.

Log in to reply