View Full Version : Static library link trouble

18th December 2011, 03:55
Some of you experts tried to help me with this about a year ago (much appreciated) but I just could not get it working. So I put it aside to work on other things until now.
I have done more research and I think I understand a little more, but I still can't get it working.

Here is the situation. I have a C library I want to link to as a static library. It was built using MingW/gcc. I have both the dll and .a library files, as well as the header files. The header file contains #ifdef __cplusplus extern "C" { #endif .... #ifdef __cplusplus } #endif and the functions all have DLLEXPORTDATA extern on them.

So I looked at a lot of posts and tried all of these in my .pro file

INCLUDEPATH += "C:/development/qt_projects/hrlogger_dev_spots/debug/tqsllib/include"


LIBS += "C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib/libtqsllib.a"

//or this
LIBS += "C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib/libtqsllib.lib"

//or this
LIBS += "C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib/libtqsllib"

with the same library file named with all of those extensions on it in that directory.

All to no avail. No joy. When I include a call to a function in the library, I get an undefined reference error, which I assume means the library is not linked.
You will have to excuse me, as I am not a C/C++ expert and I may not use the correct terminology.

I can't seem to find any Qt doc that explains how to do this.

Can someone please tell me where I am going wrong? Any help greatly appreciated.

18th December 2011, 17:54
Hi Waynew.

LIBS += -L C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib -ltqsllib

From the docs: link (http://developer.qt.nokia.com/doc/qt-4.8/qmake-project-files.html#id-0acc8e57-2f5f-49b2-8056-5aacc8af14b3)

18th December 2011, 18:43
yeah thanks norobro, I tried that. The application crashes on startup with "exited with code -1073741701" which it appears has something to do with not being able to find the library file I think.