View Full Version : adding external .lib

11th April 2009, 18:43

i'm just a noob in Qt programing and i can't figure this out:

i'm using Qt 4.4.3 integrated with Wascana version of Eclipse CDT under vista. i'm trying to add an external .lib to my project for handling a parallel port (inpout32). I edited my .pro like so:

QT += core gui
HEADERS += testlpt.h

LIBS += C:/libraries/inpout32.lib
INCLUDEPATH = C:/libraries

SOURCES = main.cpp \

FORMS += testlpt.ui

when i try to compile the whole thing i get this:

debug/testlpt.o(.text+0x77a): In function `ZN7testLPT8OnOffLPTEv':
C:/Naukowe Bzdety/Wascana Workspaces/Workspace/testLPT/testlpt.cpp:32: undefined reference to `_Z18IsInpOutDriverOpenv@0'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\testLPT.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Naukowe Bzdety/Wascana Workspaces/Workspace/testLPT'
mingw32-make: *** [debug] Error 2

can anyone please tell me what is the problem here?? :eek:

11th April 2009, 18:46
i should probably add that "IsInpOutDriverOpen();" is the only function from the library i want to add and testLPT::OnOff(); is the function that calls it :D

12th April 2009, 11:59
well, i know now that this has nothing to do with the .h file. it looks like the .lib is not being linked with my project. it seems that lots of people have the same problem. could anyone please post some hints or direct me to some usefull info? :)

12th April 2009, 21:54
Qt's .lib managment is starting to piss me off.. scaning Qt forums i found lots of threads describing the same problem: linking third party libraries to peoples Qt projects (none were resolved). HAS ANYONE EVER DONE THAT SUCCESFULLY IN HIS PROJECT ?????????????!!!!!!!!!!!!!!! :confused:

15th April 2011, 03:48
I know this thread has been down for a couple of years, but I am having the same problem. Don't suppose you found a solution did you Sqvarek?

18th April 2011, 05:54
Ok, so I've not actually gone ahead and tried this solution, but I am sure the problem lies in the compatibilty between MSVC and Ming according to this:


MSVC and MinGW, we discovered, use different naming conventions for stdcall functions. MSVC exports them as _name@ordinal, but MinGW exports them as name. As a result, the MinGW build failed with “undefined references” link errors when calling stdcall functions exported from the MSVC library.

The MinGW FAQ discusses this problem and offers a solution:

Create a definition file using reimp (for lib files) or pexports (for dll files).
Remove the underscore prefixes from the stdcall functions.
Use dlltool to convert the MSVC library into a MinGW library with the new definition.

That didn’t work. We finally removed the ordinals from the function names, which caused it to compile. But the program wouldn’t run because it couldn’t find the linked functions in the DLL. Finally, after consulting the MSDN documentation for definition files, we changed the build instructions:

Create a definition file using reimp.
For each stdcall function (formatted as _name@ordinal) add a line name = _name@ordinal, allowing MinGW to map its stdcall naming convention to that of MSVC.
Use dlltool to convert the MSVC library into a MinGW library with the new definition.

It worked! To compile the project you must simply:

Download and install the Qt/Windows package, which includes MinGW.
Download reimp and drop it into the MinGW/bin folder.
Download the development packages for the third-party libraries and point an environment variable to that location.
Build the project with the usual qmake/make commands.

I might try and recompile the source code of the libraries with Ming as I have access to it.

I hope this helps someone.