Results 1 to 4 of 4

Thread: Including a static library

  1. #1
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Including a static library

    Hi.
    I'm trying to add an external library (libmesh) to a project that must be created under Linux environment.

    I've downloaded and compiled the library myself, so it's in a not standard location. The location is in

    mydir/lib/libmesh.so

    while headers are located in

    mydir/include

    in this directory I've many subfolders (base, geom etc).

    The first thing that I'd like to know is how I can include all include subfolders without declare a INCLUDEPATH for everyone, but telling that I want to use all subfolders of mydir/include.

    Then, I'd like to know how include the .so file in my project.

    I've tried to use

    LIBS += $$quote(mydir/lib/libmesh.so)

    and

    LIBS += -L$$quote(mydir/lib/libmesh.so)

    but nothing happens: I got a lot of "undefined reference" errors.

    Have you any suggestion?

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Including a static library

    For include subdirs try with

    Qt Code:
    1. SUBPATH = $$system(ls include)
    2. for(d, SUBPATH):INCLUDEPATH += include/$$d
    To copy to clipboard, switch view to plain text mode 


    The correct syntax for libraries is

    Qt Code:
    1. LIBS += -L$$quote(mydir/lib) -lmesh
    To copy to clipboard, switch view to plain text mode 
    Last edited by mcosta; 5th May 2011 at 16:36. Reason: updated contents
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    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: Including a static library

    Quote Originally Posted by jepessen View Post
    Have you any suggestion?
    If the library file you wish to link against has a name ending in .so then it is a dynamic library, not a static library which would end in .a. If both dynamic and static versions of the library exists, then the linker will usually take the dynamic library by default.

  4. #4
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Including a static library

    Thanks for our reply.

    I've seen the QMake documentation and I've seen some example. Thanks. I've another problem, but I'll put it in another thread.
    Thanks again to everyone.

Similar Threads

  1. Replies: 2
    Last Post: 19th February 2011, 11:26
  2. Problem including library (dllimport)
    By cae in forum Qt Programming
    Replies: 9
    Last Post: 28th May 2010, 06:53
  3. Using a static library
    By Cruz in forum Newbie
    Replies: 2
    Last Post: 26th January 2010, 17:00
  4. how to use static library in qt4?
    By hashb in forum Qt Programming
    Replies: 9
    Last Post: 28th October 2009, 12:46
  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.