Important: Please read the Qt Code of Conduct -

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

  • 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.input3, etc.
    // Function
    A.Design() - function that executes what's needed to be done.
    // Outputs:
    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.

  • Having spent the better part of today researching similar issues, here's the best reference I could find on Stack Overflow. Based on my reading of your VBA pseudocode there, yes, HTDesigner is a class and A is an instance of that class. It has some member variables and one function. So what you are trying to do in your code right now won't work because you can't call member functions of classes loaded via QLibrary.

  • Thank you for your reply.
    I've read that post before writing here. I never used "virtual" methods and was hoping to get away without anything of that kind.

    Would you suggest any solution here?

    Once again, thank you for the feedback.

  • 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?

  • Lifetime Qt Champion

    @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++.

  • 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

    ° 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

  • @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.

  • Lifetime Qt Champion

  • @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:

    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.

  • @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:

    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

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

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

  • @VRonin @jsulm @Chris-Hennes


    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.

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

  • Lifetime Qt Champion

    @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.

  • @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.

Log in to reply