Results 1 to 4 of 4

Thread: creating and using static library

  1. #1
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default creating and using static library

    i am trying to write a static library & use it...
    i have googling a lot & still not solve my prob
    please look what i am doing & point where its goes wrong
    i will explain detail here:

    1. create static library
    choose menu
    File > New File or Project... > Other Project > C++ Library
    click button Choose...
    type (library) name: simple
    (i uncheck QtCore in required modules for simplicity)
    class name "Simple" (by default) and click button Next then Finish
    a folder named simple-build-desktop will be created.

    click Build and generated file will be
    Qt Code:
    1. + debug
    2. + simple.o
    3. + libsimple.a
    4. + release
    5. + Makefile
    6. + Makefile.Debug
    7. + Makefile.Release
    To copy to clipboard, switch view to plain text mode 

    (this library only keep class Simple with default constructor.. that's all)

    2. Using the static library
    * create a new project File > new File or Project... >Qt C++ Project > Qt Console Application named UsingLib then click Next > Finish

    * copy libsimple.a to project folder (./UsingLib)

    * put LIBS += ./libsimple.a or LIBS += -lsimple

    * put #include <simple.h> in main.cpp

    try to build but it gives error:
    simple.h: No such file or directory

    i also try to put libsimple.a in c:\ (c:\libsimple.a) & use these combinations:
    LIBS += -Lc:/ -lsimple
    LIBS += c:/libsimple.a
    win32:LIBS += -Lc:/ -lsimple

    none of them work

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: creating and using static library

    The compiler did not find the file simple.h. As the error message says... So either use INCLUDEPATH with a proper location or copy also the header file to the directory or put it in a "global" directory.

  3. The following user says thank you to Lykurg for this useful post:

    indomie_seleraku (18th December 2010)

  4. #3
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: creating and using static library

    thank you... so it need .h & .a files... i thought its only .a file.

    and inside .pro file, does relative path not works here?

    LIB += libsimple.a
    LIB += ./libsimple.a
    not working (libsimple.a inside project folder)

    LIB += c:/clib/libsimple.a
    works

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: creating and using static library

    Quote Originally Posted by indomie_seleraku View Post
    and inside .pro file, does relative path not works here?
    Use the -L parameter to point the compiler to your libraries. Also you are making a shadow build so the library is probably not in the current directory.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    indomie_seleraku (18th December 2010)

Similar Threads

  1. Using a static library
    By Cruz in forum Newbie
    Replies: 2
    Last Post: 26th January 2010, 17:00
  2. how to use static library in qt4?
    By hashb in forum Qt Programming
    Replies: 9
    Last Post: 28th October 2009, 12:46
  3. Static library?
    By shiranraviv in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2009, 14:11
  4. Creating Static library with QT
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 21st December 2008, 04:50
  5. Creating Static libraries in Qt/Mac
    By nareshqt in forum Qt Programming
    Replies: 0
    Last Post: 2nd May 2008, 11:45

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.