Results 1 to 6 of 6

Thread: Problem linking external libraries to .pro file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    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: Problem linking external libraries to .pro file

    I really am struggling with why the simple task of linking to an external library causes so many people grief.

    Set up the library

    Starting with the source tar ball, build and install libvlc-qt:
    Qt Code:
    1. tar xzf libvlc-qt_0.4.0_src.tar.gz
    2. cd libvlc-qt-0.4.0/
    3. mkdir build
    4. cd build
    5. cmake .. -DCMAKE_INSTALL_PREFIX=/usr
    6. make
    7. make install
    To copy to clipboard, switch view to plain text mode 


    Compile your program

    At this point your compiler will find the include files and link libraries on its own. The library will be found at runtime.

    However, if you use a different install prefix, for example /usr/local, then you need these in your pro file:
    Qt Code:
    1. INCLUDEPATH += /usr/local/include
    2. LIBS += -L/usr/local/lib
    To copy to clipboard, switch view to plain text mode 
    to tell the compiler and linker where to look.

    In all cases you need to tell Qt to link the vlc-qt library into your program:
    Qt Code:
    1. LIBS+= -lvlc-qt
    To copy to clipboard, switch view to plain text mode 
    At this point the program is compiling and linking.


    Running the Program

    If you used the standard install prefix then your program will just run without further effort.

    If you have not used a "standard" install prefix then the runtime library will not be found when you try to run it. You can use LD_LIBRARY_PATH variable to locally change the run time library search path.
    Qt Code:
    1. export LD_LIBRARY_PATH=/some/odd/install/prefix/lib
    2. ./my_program
    To copy to clipboard, switch view to plain text mode 
    Last edited by ChrisW67; 10th December 2010 at 23:33.

Similar Threads

  1. Replies: 4
    Last Post: 22nd May 2011, 13:36
  2. Using external libraries
    By Handi in forum Newbie
    Replies: 5
    Last Post: 9th December 2010, 22:51
  3. problem compiling qt application using static external libraries
    By pavan1984 in forum Installation and Deployment
    Replies: 0
    Last Post: 5th October 2010, 11:41
  4. Problem when linking with own static libraries
    By herveT in forum Qt Programming
    Replies: 4
    Last Post: 6th May 2009, 08:23
  5. Replies: 0
    Last Post: 2nd March 2009, 12:49

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.