Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there a way to make a library that can be used with other compilers (C++) in QT
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 278 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AI_Messiah
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      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.

      1 Reply Last reply
      7
      • kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by kshegunov
        #3

        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.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        7

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved