Results 1 to 3 of 3

Thread: Static library link trouble

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Static library link trouble

    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
    Qt Code:
    1. INCLUDEPATH += "C:/development/qt_projects/hrlogger_dev_spots/debug/tqsllib/include"
    2.  
    3. //then
    4.  
    5. //this
    6. LIBS += "C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib/libtqsllib.a"
    7.  
    8. //or this
    9. LIBS += "C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib/libtqsllib.lib"
    10.  
    11. //or this
    12. LIBS += "C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib/libtqsllib"
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Static library link trouble

    Hi Waynew.

    Try:
    Qt Code:
    1. LIBS += -L C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib -ltqsllib
    To copy to clipboard, switch view to plain text mode 

    From the docs: link

  3. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Static library link trouble

    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.

Similar Threads

  1. Replies: 2
    Last Post: 19th February 2011, 11:26
  2. Can I link shared library in static build program?
    By berlinud in forum Installation and Deployment
    Replies: 1
    Last Post: 27th August 2010, 16:36
  3. statically link Qt libraries (not build static library)
    By mcarter in forum Qt Programming
    Replies: 3
    Last Post: 1st February 2010, 20:42
  4. Replies: 2
    Last Post: 7th September 2009, 21:13
  5. Trouble linking static library
    By russdot in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2009, 10:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.