PDA

View Full Version : Problem linking external libraries to .pro file



baluk
9th December 2010, 22:12
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



LIBS+= -L/home/baluk/NokiaQtSDK/Vexample-build-desktop -llibvlc-qt


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

ChrisW67
9th December 2010, 22:56
Go and read the other thread that you half asked this question in:
http://www.qtcentre.org/threads/32920-Using-external-libraries?p=169677#post169677

Assuming the library files are actually in Vexample-build-desktop (I don't think that likely):


LIBS += -L/home/baluk/NokiaQtSDK/Vexample-build-desktop -lvlc-qt

baluk
10th December 2010, 07:29
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



LIBS+= -L/home/libvlc-qt-0.4.0/src -lvlc-qt
INCLUDEPATH += /home/libvlc-qt-0.4.0/src


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

baluk
10th December 2010, 13:07
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

ChrisW67
10th December 2010, 23:26
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:


tar xzf libvlc-qt_0.4.0_src.tar.gz
cd libvlc-qt-0.4.0/
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
make install



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:


INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib
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:


LIBS+= -lvlc-qt

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.


export LD_LIBRARY_PATH=/some/odd/install/prefix/lib
./my_program

baluk
11th December 2010, 13:49
Hi thanks for the neat explanation , I got it workable now. And I am sorry for many posts regarding this.