Katoch
Katoch

Reputation: 2777

Using a DLL created in Visual Studio with Qt

I have a DLL created in Visual Studio. It is for Peak USB to CAN device. This DLL is given by the vendor.

Now i want to use this DLL inside a Qt GUI. I am using default compiler of Qt to compile the Qt GUI application.

Is it possible to use this DLL created in Visual Studio directly inside Qt application?

What is exact procedure for this? I am doing it first time so please suggest.

Do gui & dll have to be compiled with same compiler to use properly?

Edit :
how can i confirm what i have installed .. means what compiler is used by QT on my PC ? i have installed using following offline installer QtSdk-offline-win-x86-v1_2_1.exe is it MSVC specific ?

Upvotes: 1

Views: 3695

Answers (3)

Fay100
Fay100

Reputation: 175

use QLibrary. I tried Qt() to call DLL(FORTRAN). it works well. wish it coud help

Upvotes: 0

Frank Osterfeld
Frank Osterfeld

Reputation: 25155

With "default compiler of Qt" you probably mean mingw.

Using MSVC-compiled DLLs will not work then. DLLs compiled from C++ with MingW and MSVC are ABI-incompatible to each other, i.e. cannot be mixed (plain C libraries work though).

I suggest to download Qt for MSVC and use that.

Upvotes: 2

David Grayson
David Grayson

Reputation: 87386

Yes, it is possible and I have done it before. I am assuming you are talking about a Win32 DLL, probably written in C. Using any language other than C could be tricky.

I don't remember the exact procedure but here is the outline:

  1. Configure your QT app to link to the .lib (import library binary) for the DLL. I think you need to edit the main QMake config file.
  2. Add an include in your Qt app for the DLL's header (.h) file.
  3. Add a Qt post-build step to copy that DLL to your app directory so it can be found and loaded at runtime.

Upvotes: 0

Related Questions