Results 1 to 2 of 2

Thread: Adding an external Library

  1. #1
    Join Date
    Jul 2008
    Posts
    48
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Adding an external Library

    Hi everyone,

    How do I add an external library to my qt project. Currently, I build simply by doing
    qmake -project
    qmake
    make

    but I need to add a CXXFLAGS and LDFLAGS to link with an external library as well.

    Ted.

  2. #2
    Join Date
    Dec 2008
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Adding an external Library

    You normally only use the command "qmake -project" once. This generates a project file (something.pro). This contains various settings about your application and how to build it.
    To make it link in an additional library, you add the LIBS variable to this file:
    QMake Code:
    1. LIBS += -lmylib
    To copy to clipboard, switch view to plain text mode 
    (that's "-l" (small L) directly followed by the library name).

    If the library is in a directory the linker doesn't look in, you add the path to it to the LIBS variable:
    QMake Code:
    1. LIBS += -L/path/to/my/lib -lmylib
    To copy to clipboard, switch view to plain text mode 

    On Windows, it is recommended to omit the -L, and just use the full path with -l, like:
    QMake Code:
    1. LIBS += -lc:/path/to/my/lib/mylib.lib
    To copy to clipboard, switch view to plain text mode 

    When you are done editing the .pro file, save it and run qmake -makefile. This generates a makefile from your .pro file. Run the makefile by typing "make".

    This and much much more is all explained in qmake-manual.
    Last edited by wysota; 2nd January 2009 at 23:17.

Similar Threads

  1. Replies: 7
    Last Post: 22nd December 2010, 08:13
  2. shared vs static
    By alisami in forum Installation and Deployment
    Replies: 3
    Last Post: 4th October 2008, 13:04
  3. Replies: 16
    Last Post: 23rd May 2008, 10:12
  4. Adding library dependencies to qmake
    By sadastronaut in forum Installation and Deployment
    Replies: 2
    Last Post: 18th March 2008, 17:06
  5. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04

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.