PDA

View Full Version : Lib path



yagabey
3rd April 2009, 09:15
Hello,

What is the difference between "setting the env var "LD_LIBRARY_PATH=./blabla" " and setting LIBS += -L./blabla in the project file. Ive thought they do the same job;but usually i am getting have to set the LD_LIBRARY_PATH to make my application working...

thanks in advance...

wysota
3rd April 2009, 10:00
LIBS+= is something related to the compiler (it tells the compiler/linker where to look for libraries it might need and which ones to link against your application). LD_LIBRARY_PATH is something related to your system's dynamic linker that does its job when an application is being started (it tells the dynamic linker where to look for libraries that need to be put into your process's address space). You can compile and run the application on different machines so an absolute and hard path would be a bad idea.

yagabey
3rd April 2009, 15:38
Thanks, it is clear now... Should i always use "export LD_LIBRARY_PATH" command for dynamic libraries? In windows, it is enough to put the dll s into the same directory with executable; but for linux i have to use "export LD_LIBRARY_PATH=."

talk2amulya
3rd April 2009, 15:40
yes, plus u can always create a small shell script for it

wysota
3rd April 2009, 16:01
Thanks, it is clear now... Should i always use "export LD_LIBRARY_PATH" command for dynamic libraries? In windows, it is enough to put the dll s into the same directory with executable; but for linux i have to use "export LD_LIBRARY_PATH=."

You can place the libraries in a directory where the linker will look for it. It's the same in Windows, only that in Windows one of those directories is the directory containing the executable. On Linux it is not, probably due to security reasons. Instead od using LD_LIBRARY_PATH you can add the path to /etc/ld.so.conf.d/ or /etc/ld.so.conf.