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. Using 3rd Party DLL in Qt application. No .h or .lib files. Only Excel with I/O list
Forum Updated to NodeBB v4.3 + New Features

Using 3rd Party DLL in Qt application. No .h or .lib files. Only Excel with I/O list

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 Posters 4.7k Views
  • 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 Adil

    I've done a lot of search on the Internet and could only get bits and pieces of an answer I am looking for. Fairly new using DLLs so please bear with any "stupid" questions that might occur.

    • I am using Qt Creator IDE with Mingw compiler
    • I have a DLL from a 3rd party that was built in Visual Studios 2015 using Framework .NET 4.0 and coding language VB.NET
    • Along with DLL I have Excel file that has list of inputs, 1 function, and outputs. Also Excel has a description of inputs variable types (string, double, etc). Here is what is inside of excel:
    // not sure what this is
    Dim Message As String
    Dim A As HTDesigner
    A = New HTDesigner
    On Error GoTo ErrorHandler
    
    // Inputs used:
    A.input1
    A.input2
    A.input3, etc.
    
    // Function
    A.Design() - function that executes what's needed to be done.
    
    // Outputs:
    A.output1
    A.output2
    A.output3, etc. 
    

    Here is the list of questions:

    1. Is "HTDesigner" a class inside of DLL and "A" is just a name of the class?
    2. Can I use "QLibrary" and its "resolve" function in my Qt program for this case?
    3. I tried to use "resolve" to call the "A.Design" function separately but there is an error because I think the function is a part of a class.

    Basically, I need to use my list of inputs, plug into DLL which will use the function and get the list of outputs. Hopefully this was clear enough.

    Thank you in advance for any feedback.

    VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by VRonin
    #6

    Mingw compiler [...] Visual Studios 2015

    You cannot mix them, you'll have to use VS2015 too, you can download the community version for free here if you meet the requirements of the free license

    Framework .NET 4.0 and coding language VB.NET

    VB.Net, C# and C++/CLI all compile to an intermediate common CLR format. this allows libraries written in any of these languages to link against applications or libraries written in other languages.

    In my experience, mixing Qt with .Net has been problematic (looking at the bug tracker at the moment only QStateMachine seems to report problems) so what I usually do is insulate the C++/CLI in a separate executable and use QProcess to manage it (a bit more detail: I use standard input and output as they were a socket transmitting data stored in a QByteArray and using toBase64() to convert it to text).

    In short:

    • Create 2 projects, one linking to Qt, the other using CLR*
    • In the project using CLR link to the VB.Net library
    • .Net also allows you to interact easily with Office Applications°
    • Use QProcess to make the two applications talk to each other

    *To use CLR in Qt Creator disabling the link to Qt, in your .pro file add:

    CONFIG -= qt
    QMAKE_CXXFLAGS += -clr
    QMAKE_CXXFLAGS_STL_ON -= -EHsc
    QMAKE_CXXFLAGS_EXCEPTIONS_ON -= -EHsc
    

    ° It's usually more efficient to google for C# code rather than C++/CLI and convert it to C++/CLI

    As the starting point to understand C++/CLI, Ivor Horton's book is not bad

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    A 1 Reply Last reply
    0
    • jsulmJ jsulm

      @Adil You cannot use a DLL compiled with compiler A in a project compiled with compiler B.
      That means you either get this DLL built using MinGW or you use Visual C++ compiler (exact same version as used for the DLL).
      If this DLL is a managed one you will need to use Qt for Windows RT and Visual C++.

      A Offline
      A Offline
      Adil
      wrote on last edited by
      #7

      @jsulm Thank you for your feedback. Since there is no way this DLL will be compiled using MinGW I will have to go with an option of using Visual C++ compiler.

      1. Can I download ONLY compiler and not the whole package?
      2. Is there any way to figure out whether the DLL is managed or not?

      Thank you in advance, appreciate the help.

      jsulmJ 1 Reply Last reply
      0
      • A Adil

        @jsulm Thank you for your feedback. Since there is no way this DLL will be compiled using MinGW I will have to go with an option of using Visual C++ compiler.

        1. Can I download ONLY compiler and not the whole package?
        2. Is there any way to figure out whether the DLL is managed or not?

        Thank you in advance, appreciate the help.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #8

        @Adil

        1. https://blogs.msdn.microsoft.com/vcblog/2016/11/16/introducing-the-visual-studio-build-tools/
        2. http://stackoverflow.com/questions/5275985/is-this-dll-managed-or-unmanaged

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • VRoninV VRonin

          Mingw compiler [...] Visual Studios 2015

          You cannot mix them, you'll have to use VS2015 too, you can download the community version for free here if you meet the requirements of the free license

          Framework .NET 4.0 and coding language VB.NET

          VB.Net, C# and C++/CLI all compile to an intermediate common CLR format. this allows libraries written in any of these languages to link against applications or libraries written in other languages.

          In my experience, mixing Qt with .Net has been problematic (looking at the bug tracker at the moment only QStateMachine seems to report problems) so what I usually do is insulate the C++/CLI in a separate executable and use QProcess to manage it (a bit more detail: I use standard input and output as they were a socket transmitting data stored in a QByteArray and using toBase64() to convert it to text).

          In short:

          • Create 2 projects, one linking to Qt, the other using CLR*
          • In the project using CLR link to the VB.Net library
          • .Net also allows you to interact easily with Office Applications°
          • Use QProcess to make the two applications talk to each other

          *To use CLR in Qt Creator disabling the link to Qt, in your .pro file add:

          CONFIG -= qt
          QMAKE_CXXFLAGS += -clr
          QMAKE_CXXFLAGS_STL_ON -= -EHsc
          QMAKE_CXXFLAGS_EXCEPTIONS_ON -= -EHsc
          

          ° It's usually more efficient to google for C# code rather than C++/CLI and convert it to C++/CLI

          As the starting point to understand C++/CLI, Ivor Horton's book is not bad

          A Offline
          A Offline
          Adil
          wrote on last edited by
          #9

          @VRonin
          Thank you very much for such a detailed reply. I have just registered yesterday and it is amazing people put this much effort to help each other :)

          Am I correct to assume that method you described is different from the one here: http://doc.qt.io/qt-5.8/activeqt-dotnet.html?

          It will take me some time to digest all this.
          For this particular problem, theoretically, would it be easier if I was using Visual Studio IDE with VC++ compiler?

          Thank you once again for your help.

          VRoninV 1 Reply Last reply
          0
          • A Adil

            @VRonin
            Thank you very much for such a detailed reply. I have just registered yesterday and it is amazing people put this much effort to help each other :)

            Am I correct to assume that method you described is different from the one here: http://doc.qt.io/qt-5.8/activeqt-dotnet.html?

            It will take me some time to digest all this.
            For this particular problem, theoretically, would it be easier if I was using Visual Studio IDE with VC++ compiler?

            Thank you once again for your help.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #10

            @Adil said in Using 3rd Party DLL in Qt application. No .h or .lib files. Only Excel with I/O list:

            Am I correct to assume that method you described is different from the one here: http://doc.qt.io/qt-5.8/activeqt-dotnet.html?

            Not radically (the MC++ is pretty close to my solution), but yes

            would it be easier if I was using Visual Studio IDE

            Only marginally, VS might have better handling of C++/CLI syntax but that's pretty much it

            would it be easier if I was using [..] VC++ compiler

            You actually have no other choice afaik

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            A 2 Replies Last reply
            1
            • VRoninV VRonin

              @Adil said in Using 3rd Party DLL in Qt application. No .h or .lib files. Only Excel with I/O list:

              Am I correct to assume that method you described is different from the one here: http://doc.qt.io/qt-5.8/activeqt-dotnet.html?

              Not radically (the MC++ is pretty close to my solution), but yes

              would it be easier if I was using Visual Studio IDE

              Only marginally, VS might have better handling of C++/CLI syntax but that's pretty much it

              would it be easier if I was using [..] VC++ compiler

              You actually have no other choice afaik

              A Offline
              A Offline
              Adil
              wrote on last edited by
              #11

              @VRonin Thank you. I will try this solution and will let you know.

              1 Reply Last reply
              0
              • Chris HennesC Chris Hennes

                I missed the fact that this is a .NET DLL, which probably (hopefully) means that it is a "managed DLL" rather than a pure native C++ DLL. I've never had to deal with these before, but based on my cursory reading it looks like you might be able to swing a solution via ActiveQt. Have you read this article on .NET interoperability with Qt?

                A Offline
                A Offline
                Adil
                wrote on last edited by
                #12

                @Chris-Hennes Thank you for this link provided. I will try out the solution suggested in there.

                1 Reply Last reply
                0
                • VRoninV VRonin

                  @Adil said in Using 3rd Party DLL in Qt application. No .h or .lib files. Only Excel with I/O list:

                  Am I correct to assume that method you described is different from the one here: http://doc.qt.io/qt-5.8/activeqt-dotnet.html?

                  Not radically (the MC++ is pretty close to my solution), but yes

                  would it be easier if I was using Visual Studio IDE

                  Only marginally, VS might have better handling of C++/CLI syntax but that's pretty much it

                  would it be easier if I was using [..] VC++ compiler

                  You actually have no other choice afaik

                  A Offline
                  A Offline
                  Adil
                  wrote on last edited by Adil
                  #13

                  @VRonin @jsulm @Chris-Hennes

                  Update:

                  1. Qt documentation states:
                    "The MS compilers for C# and VB.NET will only produce managed code. Such programs cannot directly call normal, native functions or classes."
                    Since I've been told that DLL was written in VB.Net I will assume it's managed.

                  2. Different forum threads and Stackflow posts suggest that it's fairly easy to implement .NET DLL components in Qt code using ActiveQt framework because there is a "COM Interop". I've only found examples of reverse process, using ActiveQt to help .NET code to read Qt DLL (and even these are not clear to me).

                  I know nothing about ActiveQt but apparently it should help me to solve the problem. Hopefully it's not too complicated.

                  UPDATE:
                  I've just come to find out that ActiveQt framework is not part of an open source package. So no go here.

                  jsulmJ 1 Reply Last reply
                  0
                  • A Adil

                    @VRonin @jsulm @Chris-Hennes

                    Update:

                    1. Qt documentation states:
                      "The MS compilers for C# and VB.NET will only produce managed code. Such programs cannot directly call normal, native functions or classes."
                      Since I've been told that DLL was written in VB.Net I will assume it's managed.

                    2. Different forum threads and Stackflow posts suggest that it's fairly easy to implement .NET DLL components in Qt code using ActiveQt framework because there is a "COM Interop". I've only found examples of reverse process, using ActiveQt to help .NET code to read Qt DLL (and even these are not clear to me).

                    I know nothing about ActiveQt but apparently it should help me to solve the problem. Hopefully it's not too complicated.

                    UPDATE:
                    I've just come to find out that ActiveQt framework is not part of an open source package. So no go here.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    @Adil I never used ActiveQt but I'm quite sure it is open source. From where do you have this information?
                    I don't think ActiveX will help you. ActiveX is used for to use ActiveX controls and COM provided by ActiveX servers - it is some kind of interprocess communication.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    A 1 Reply Last reply
                    1
                    • jsulmJ jsulm

                      @Adil I never used ActiveQt but I'm quite sure it is open source. From where do you have this information?
                      I don't think ActiveX will help you. ActiveX is used for to use ActiveX controls and COM provided by ActiveX servers - it is some kind of interprocess communication.

                      A Offline
                      A Offline
                      Adil
                      wrote on last edited by
                      #15

                      @jsulm I think I've read really old documentation that stated it wasn't free. I will check one more time.
                      From what I've been reading there is a "dumpcpp" tool that should help. Thanks for your feedback.

                      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