Results 1 to 4 of 4

Thread: Working with a static library I have written in Qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Posts
    41
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Exclamation Working with a static library I have written in Qt

    Hi all !

    Here is my problem : I have a project that has two subprojects, both are libraries. One is QJson and the other one is home-made and uses Qt. I then have an other project that will use these two libraries. I want this main project to use my set of library statically.

    Here is what I have in my .pro :

    Qt Code:
    1. LIBS += -L$$PWD/../../../libmylib/lib/
    2. LIBS += -lqjson -lmylib
    3.  
    4.  
    5. INCLUDEPATH += $$PWD/../../../libmylib/include
    6. DEPENDPATH += $$PWD/../../..libmylib/include
    To copy to clipboard, switch view to plain text mode 

    Everything works fine under MAC OS X.

    Now, I want this project to work on Windows. And here are the issues. My main project complains about undefined references to mylib. MyLib project has generated qjson.a and qjson.dll, mylib.a (no dll).

    Shouldn't my library be outputed as a .lib ? Why don't I have a dll for mylib ?

    Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Working with a static library I have written in Qt

    The linker command typically assumes dynamic linking, try listing the library file explicitly:
    Qt Code:
    1. LIBS += -lqjson $$PWD/../../../libmylib/lib/mylib.a
    To copy to clipboard, switch view to plain text mode 

    You are getting the .a suffix because you are using (I assume) the MinGW/GCC compiler.
    You get no DLL because I assume you pro file for mylib specifies static in the CONFIG variable.
    Last edited by ChrisW67; 10th November 2011 at 22:37.

Similar Threads

  1. Replies: 4
    Last Post: 6th March 2011, 12:10
  2. Replies: 2
    Last Post: 19th February 2011, 11:26
  3. Replies: 0
    Last Post: 22nd February 2010, 16:36
  4. Using a static library
    By Cruz in forum Newbie
    Replies: 2
    Last Post: 26th January 2010, 17:00
  5. Static library?
    By shiranraviv in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2009, 14:11

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.