Results 1 to 6 of 6

Thread: Using external libraries

  1. #1
    Join Date
    Jul 2010
    Posts
    13
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Using external libraries

    Hello, I'm working in Qt Creator/Win7, and have been trying to understand how to use external libraries for 2 hours already.

    I've read the qmake documentation and looked for info on google but I didn't find any satisfactory examples.

    I've added qextserialportd.dll and qwt5.dll files to my main directory where all the project files are.

    here is my .pro file:
    Qt Code:
    1. QT += core gui
    2.  
    3. TARGET = myser2
    4. TEMPLATE = app
    5.  
    6.  
    7. SOURCES += main.cpp\
    8. myser2.cpp
    9.  
    10. HEADERS += myser2.h
    11.  
    12. FORMS += myser2.ui
    13.  
    14. LIBS += -lqextserialportd
    15. LIBS += -lqwt5
    To copy to clipboard, switch view to plain text mode 

    in myser2.h, I've put
    Qt Code:
    1. #include <qextserialport.h>
    2. #include <qwt_plot.h>
    To copy to clipboard, switch view to plain text mode 

    now, when I try to build, it can't find any of those files.
    I've tried all sorts of different notations for LIBS:
    Qt Code:
    1. LIBS += <path>/qwt5.lib
    2. LIBS += <path>/qwt5.dll
    3. LIBS += qwt5.lib
    4. LIBS += -L<path> -lqwt5
    To copy to clipboard, switch view to plain text mode 
    but nothing works

    If you could explain me what I am forgetting, that would be great. An example project would be even better.
    Thanks

  2. #2
    Join Date
    Jul 2010
    Posts
    21
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using external libraries

    Hi,

    Use INCLUDEPATH to define the location of your header files, LIBPATH to define the location of your libraries, and LIBS to define the libs. For example

    INCLUDEPATH += c:\qwt\include
    LIBPATH += c:\qwt\lib
    LIBS += -lqwt5

    Hope this helps.

  3. #3
    Join Date
    Jul 2010
    Posts
    13
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using external libraries

    Thanks, but my libs are in the same folder as all my project files which is:

    C:\Users\Pavel\Desktop\Pavel\Programs\Qt\myser2

    I tried to add
    Qt Code:
    1. INCLUDEPATH += C:\Users\Pavel\Desktop\Pavel\Programs\Qt\myser2
    2. LIBPATH += C:\Users\Pavel\Desktop\Pavel\Programs\Qt\myser2
    3.  
    4. or
    5.  
    6. INCLUDEPATH += .
    7. LIBPATH += .
    To copy to clipboard, switch view to plain text mode 

    but it doesn't work. I put my project on rapidshare (qtcentre has a 244k limit for zip files ), maybe you could take a look:
    http://rapidshare.com/files/410065957/myser2.zip

    EDIT: Btw, when I include compiled libraries to my project, I do not need to also include all the header files that were used to compile that library, do I?
    For instance, when I include qextserialport.h, does it look for it inside qextserialportd.dll or not?
    Last edited by Handi; 30th July 2010 at 21:56.

  4. #4
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using external libraries

    Hi Handi,

    I am getting the same error. i am wondering if you have overcome the problem. If so please let me know the solution.

  5. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Using external libraries

    Quote Originally Posted by baluk View Post
    Hi Handi,

    I am getting the same error. i am wondering if you have overcome the problem. If so please let me know the solution.
    What error? The only thing mentioned above is that something "can't find any of those files" or "it doesn't work." An actual error message would be quite helpful, but I don't see any. At a minimum, it would illuminate whether the problem is an inability to locate the header files or the library files.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,626
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Using external libraries

    To quote and repair an earlier answer in this thread.

    At compile time:
    • Use INCLUDEPATH to define extra locations to be searched for header files
    • Use LIBS -L options to define extra locations to be searched for libraries
    • Use LIBS -l options to name the libs to be used.

    Example:
    Qt Code:
    1. INCLUDEPATH += /home/me/foo/include
    2. LIBS += -L/home/me/foo/lib -lfoo
    To copy to clipboard, switch view to plain text mode 

    At run time the dynamically loadable libraries must be locatable by the operating system:
    • On Windows: In the current working directory of the executing process (note that this is rarely the same as the source code directory) or on the system PATH.
    • On Linux: In directories listed in the LD_LIBRARY_PATH environment variable (if it exists) and on the system library path (see /etc/ld.so.conf). See man ld.so for other, less used options.
    • On Mac OS X: Probably similar to Linux but bound to be different in detail.

Similar Threads

  1. QtCreator and external libraries
    By GiuseppeBonfa in forum Qt Tools
    Replies: 6
    Last Post: 21st May 2012, 23:26
  2. Replies: 4
    Last Post: 22nd May 2011, 13:36
  3. How to add external Header files and libraries?
    By askbapi in forum Installation and Deployment
    Replies: 6
    Last Post: 30th September 2010, 17:33
  4. Replies: 4
    Last Post: 7th May 2009, 07:19
  5. add external api
    By adamatic in forum Qt Programming
    Replies: 6
    Last Post: 16th April 2009, 10:25

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.