You are not logged in.

1

Thursday, July 29th 2010, 7:37am

Use DLL from MVC with MinGW

Hi,

I search for a way to use a DLL written with Visual Studio 2005 in my Qt application using the MingGW compiler 8|.

What I have managed to do so far is providing the .lib and header to the project:

Source code

1
2
INCLUDEPATH += "..\InputHook" 
LIBS += "..\debug\InputHook.lib"


and including the header file in my source:

Source code

1
#include "InputHook.h"


Now if I try to call a function of the DLL:

Source code

1
DisableKeys(&Entry);


I get following linker error :cursing: :

Source code

1
.../mainwindow.cpp:20: undefined reference to `_imp___Z11DisableKeysP9HOOKENTRY'


The function was exported using:

Source code

1
2
#define DLLIMPORT __declspec(dllimport) 
DLLIMPORT void DisableKeys(LPCHOOKENTRY lpEntry);



Has anybody an idea of how to resolve the problem ?( ? Thanks

This post has been edited 1 times, last edit by "thrall" (Jul 29th 2010, 8:52am)


2

Thursday, July 29th 2010, 1:18pm

from the linker message I guessed it is some prolbem with name mangling and I kind of solved it by surrounding my DLL import/export with

Source code

1
extern "c" {}




For me this looks like workaround, or is it common to do it this way :wacko: ?



I'm still interested in comments about this problem.

Posts: 4

Location: Everywhere... Nowhere...

Occupation: Stuff with Qt...

  • Send private message

3

Monday, August 2nd 2010, 3:46pm

Hello

Have you looked at the Mingw webpage on MSVC & Mingw DLLs? It is at:

http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs

You'll most probably need to do the steps that come after "However, for __stdcall functions....."
This is, of course, assuming that you haven't tried this already... :)

Hope this helps.
Qt is :thumbsup: