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. Qlibrary on C++ DLL
Forum Updated to NodeBB v4.3 + New Features

Qlibrary on C++ DLL

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 5.7k Views 1 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.
  • G Offline
    G Offline
    galrub
    wrote on last edited by
    #1

    Hello all, I have a dll that was compiled under MSVC 2008, I have it's lib and header files but not the source code.
    I tried using neither dlltool and reimp commands to rebuild a '.a' library file but it didn'--t work.

    so, my question is, can I use QLibrary, or any other Qt class to init instances of these classes
    knowing they are mostly singletones, like:
    @ static SomeClass * SomeClass::instance();@
    so I have to somehow call these function.

    thanks,
    G

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dmcr
      wrote on last edited by
      #2

      Hello,

      Is this a C library or a C++ one?
      You could use QLibrary with C, and construct your own objects after....
      However i am quite sure that's it's difficult to embed C++ object, as they are using the MFC, and sometimes they have some impredictible reactions, so it depends on your objects.
      But it is not a very good practice i think.

      dmcr

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Franzk
        wrote on last edited by
        #3

        [quote author="dmcr" date="1319556052"]However i am quite sure that's it's difficult to embed C++ object, as they are using the MFC, and sometimes they have some impredictible reactions, so it depends on your objects.
        But it is not a very good practice i think.[/quote]

        Correct, although not related to MFC. MSVC c++ libraries are binary incompatible to MinGW libraries. MSVC built C++ libraries are often even binary incompatible between MSVC versions. The only way you're going to be able to use it (if it's a C++ interface) is by using a corresponding MSVC version for your build. This sort of thing is the precise reason Qt is distributing binaries for both MSVC and MinGW. Pain in the butt? Certainly. Blame the C++ guys for leaving the ABI free to choose.

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • G Offline
          G Offline
          galrub
          wrote on last edited by
          #4

          thanks... I see if I can get the vendor to be a bit more.. relaxed... :-)

          thanks,
          G

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kouillo
            wrote on last edited by
            #5

            Hi !
            Did you find any solution for your problem ? I'm in the same case (a C++ library compiled with MSVC) and I want to add it in a GCC compiled project...

            Is there any way to re-compile the library ? or build an inclusion file (like a .lib) in order to help the linker ?

            Thanks.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Franzk
              wrote on last edited by
              #6

              The sanest way to work around this I think is to wrap the C++ dll in a C interface dll (using msvc express). Then you can use gcc to (dynamically) link against that. C linkage is defined, unlike C++. It's usually the easiest if the vendor doesn't supply mingw builds (like Qt does).

              "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • G Offline
                G Offline
                galrub
                wrote on last edited by
                #7

                yes:
                [quote author="Franzk" date="1328548005"]The sanest way to work around this I think is to wrap the C++ dll in a C interface dll (using msvc express). Then you can use gcc to (dynamically) link against that. C linkage is defined, unlike C++. It's usually the easiest if the vendor doesn't supply mingw builds (like Qt does).[/quote]

                this was my first solution, then I got enough budget to re-implement the stuff, so everything now is MSVC...
                because of the difference between GCC and MSVC, there is no other way then to warp the DLL (many tutorials on the web on this). or go MSVC/GCC all the way.

                1 Reply Last reply
                0

                • Login

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