Results 1 to 3 of 3

Thread: Using a static library

  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Using a static library

    Hello!

    I'm a total lamer when it comes to compiling and using libraries. Can anyone please put me on the right track? I have a Qt Project in Eclipse on Linux and so far everything compiles and works great. I want to use the newmat library for matrix operations. So I added the newmat sources to my source tree and compiled the package using the provided make files and now I have a libnewmat.a file that is supposed to be the library. How do I use this library now?

    In my source code I included

    #include <newmat/newmat.h>

    and because of this all the newmat source are recompiled each time I build my Qt project. I tried adding the library in project preferences -> C/C++ project paths -> libraries, but it doesn't change anything. What do I have to do?

    Thanks
    Cruz

  2. #2
    Join Date
    Aug 2009
    Location
    Greece, Chania
    Posts
    63
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Using a static library

    What you probably want is to dynamic compile the newmat library (.so) and use in your project the QLibrary class to load it.
    Misha R.evolution - High level Debugging IDE

    Programming is about 2 basic principles: KISS and RTFM!!!

  3. #3
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using a static library

    you just add this to your .pro file:

    for windows:
    LIBS += path/to/your/lib/libnewmat.a

    for unix:

    LIBS += -L/usr/local/lib -lnewmat

    Make sure you put that new lib in /usr/local/lib for the example above.

    I find it useful to do the following command on the final executable:

    ldd ./mynewapp

    this will give you a list of all libs the app needs and whether it was able to find them all.

  4. The following user says thank you to schnitzel for this useful post:

    Cruz (9th February 2010)

Similar Threads

  1. how to use static library in qt4?
    By hashb in forum Qt Programming
    Replies: 9
    Last Post: 28th October 2009, 12:46
  2. Static library?
    By shiranraviv in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2009, 14:11
  3. Using a Win32 static library
    By jacky in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2009, 04:39
  4. Creating Static library with QT
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 21st December 2008, 04:50
  5. Compiling QCA as static library
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2008, 17:32

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.