This forum has been archived. All content is frozen. Please use KDE Discuss instead.

linking problem Windows/MinGW

Tags: None
(comma "," separated)
tksharpless
Registered Member
Posts
3
Karma
0
OS

linking problem Windows/MinGW

Sun Mar 07, 2010 9:24 pm
Maybe someone here can answer my problem, which is perhaps elementary. I have a native Windows dll, built by me with msvc, that I wish to link to a Qt app built on MinGW with Qt 4.6 Open Source.

Adding the .lib for that dll to the Qt project seems to work OK, but I still get an undefined symbol error from ld. The symbol in question is a plain C function name; nm reports that it is indeed defined as a Target in the .lib and an external in the gcc .obj, with identical spelling.

Why is this not working? How to fix it??

Thanks, Tom
User avatar
Darkstar
Registered Member
Posts
11
Karma
0

Re: linking problem Windows/MinGW

Sun Mar 07, 2010 10:59 pm
You should avoid mixing MSVC and mingw binaries at all costs. It will break in subtle ways, like every time you want to do file I/O.

Having said that, your problem is probably due to an incorrect function declaration: cdecl vs. stdcall vs. fastcall. Try adding one of these decorations to your project (or to the function import declaration) and re-compile.

Good luck in getting it to work, but in the end it will probably be easier to just recompile everything with one compiler (that's a lesson I learned the hard way too...)


This is not a signature...
tksharpless
Registered Member
Posts
3
Karma
0
OS

Re: linking problem Windows/MinGW

Mon Mar 08, 2010 2:37 am
Thanks, but I prefer to beat my head against the wall. At least until I solve the following problem: It doesn't work with MS tools either!

That is, I built an app with msvc that tries to call this dll, and MS link also gives me the undefined symbol error, though objectdump agrees that the symbol is in the .lib. Evidently there is something wrong with how I'm building the dll. I adapted it from a Windows SDK sample that only exports PRIVATE symbols.

--Tom
tksharpless
Registered Member
Posts
3
Karma
0
OS

Re: linking problem Windows/MinGW

Mon Mar 08, 2010 2:40 am
PS I'm not trying to do a static link here. That would indeed be mixing apples & oranges. But MinGW programs link to Windows dlls all the time without problem.
User avatar
Darkstar
Registered Member
Posts
11
Karma
0

Re: linking problem Windows/MinGW

Mon Mar 08, 2010 7:25 pm
Have you tried fiddling with the linkage parameters (cdecl etc.)? Or maybe you're just missing an 'extern "C" {...}' around your function declarations?


This is not a signature...


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Sogou [Bot]