Results 1 to 6 of 6

Thread: Problem linking external libraries to .pro file

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

    Default Problem linking external libraries to .pro file

    Hi,

    I have an external library "libvlc-qt.so" and I am trying to link this library to my qt pro file. But I get the error
    Can't find "libvlc-qt
    . The line I added to. pro is

    Qt Code:
    1. LIBS+= -L/home/baluk/NokiaQtSDK/Vexample-build-desktop -llibvlc-qt
    To copy to clipboard, switch view to plain text mode 

    And then I run the build option in Qt creator. Can any one tell me What am I doing wrong in this.

    Thank You,

    Baluk

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,593
    Thanks
    13
    Thanked 1,587 Times in 1,516 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Problem linking external libraries to .pro file

    Go and read the other thread that you half asked this question in:
    http://www.qtcentre.org/threads/3292...677#post169677

    Assuming the library files are actually in Vexample-build-desktop (I don't think that likely):
    Qt Code:
    1. LIBS += -L/home/baluk/NokiaQtSDK/Vexample-build-desktop -lvlc-qt
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Problem linking external libraries to .pro file

    Hi,

    Thank you for the response. I added the lines with actual paths accordingly that you mentioned in both the posts. This time I don't see any warning message from ".pro" file but I don't see these added library header files in my mainWindow.h file when I am trying to include them with "#include <vlc-qt/ > something like this". what could be the reason for this. The lines I added are

    Qt Code:
    1. LIBS+= -L/home/libvlc-qt-0.4.0/src -lvlc-qt
    2. INCLUDEPATH += /home/libvlc-qt-0.4.0/src
    To copy to clipboard, switch view to plain text mode 

    Here I have attached the folder contains the external library and headers that I want to link to my project. Can any one please check this with your example projects and see If there is anything wrong.

    Thank You,

    baluk
    Attached Files Attached Files

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

    Default Re: Problem linking external libraries to .pro file

    I got succeed with my problem. But then again I started getting new message that says
    libvlc-qt.so: "Can't read shared object file" no such file or directory
    . I somehow solved my first problem that I could read the library class header files from the shared library. And I could even write some functionality using the classes. But all of sudden after some time my program can't able to read the object file. Anybody have an idea why is it because.

    Thank You,
    Baluk

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,593
    Thanks
    13
    Thanked 1,587 Times in 1,516 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.

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

    Default Re: Problem linking external libraries to .pro file

    Hi thanks for the neat explanation , I got it workable now. And I am sorry for many posts regarding this.
    Last edited by baluk; 11th December 2010 at 15:22.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.