Results 1 to 4 of 4

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

  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.

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

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

    Thanks for your answer. Your assumptions are true. But however, linking with the mylib.a doesn't work neither. I still get some undefined references.

    I will make some tries with samples projects...


    Added after 1 26 minutes:


    Mylib was using QJson itself. So I mixed it all and now it works with mylib as a static library. Thanks.

    Next step is to get this built for Symbian. Is there any documentation anywhere on how to link to a static library for Symbian ?

    Thanks
    Last edited by Guilo; 11th November 2011 at 21:11.

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

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

    I have found this (http://www.developer.nokia.com/Commu...Qt_for_Symbian) that tells me how to link to a symbian library. The issue is that when I built ly library for symbian, it didn't output any .lib or .dll file anywhere. Any idea ?

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.