Shared Libraries Problem...
Hi!
I'm totally lost when it comes to shared libraries on Linux.
I know that on win32, when I put the .dll file in the same folder as the executable it will be found and used.
How do I achieve same functionality with .so files on Linux?
thanks :)
_______________________________All your base are belong to us.
LD_LIBRARYPATH points to locaations where ld has to search for libs
and
/etc/ld.so.conf and /etc/ld.so.conf.d/* contain more directories to search in.
the most common place where to find libs is /usr/lib.
e.g. you could run your program like this: $ LD_LIBRARYPATH=/where/ever ./myprogram
and
/etc/ld.so.conf and /etc/ld.so.conf.d/* contain more directories to search in.
the most common place where to find libs is /usr/lib.
e.g. you could run your program like this: $ LD_LIBRARYPATH=/where/ever ./myprogram
Most libraries just move any library files into /usr/lib. This is frequently done in the "install" target of a makefile.
Quote: Original post by hydroo
LD_LIBRARYPATH points to locaations where ld has to search for libs
and
/etc/ld.so.conf and /etc/ld.so.conf.d/* contain more directories to search in.
the most common place where to find libs is /usr/lib.
e.g. you could run your program like this: $ LD_LIBRARYPATH=/where/ever ./myprogram
It's LD_LIBRARY_PATH.
And, if you add a new line to /etc/ld.so.conf or drop a text file in /etc/ld.so.conf.d, you will need to rerun ldconfig to regenerate the search cache file (/etc/ld.so.cache).
The default place ld-linux.so (the dynamic linking loader) looks is usually /usr/lib and then /lib (see ld.so(8) for documentation).
Stephen M. Webb
Professional Free Software Developer
If you are using gcc (or g++) you can use "-Wl,-rpath=/The/Search/Path" to put the search path directly into the executable.
Quote: "-Wl,-rpath=/The/Search/Path"
It would seem it's exactly what I'm looking for, thanks!
Quote: It's LD_LIBRARY_PATH.
Isn't LD_LIBRARY_PATH broken, and should not be used?
_______________________________All your base are belong to us.
Quote: Original post by Yezu
Isn't LD_LIBRARY_PATH broken, and should not be used?
I'm not aware of any such problem and we use it all the time in both commercial and free software products I work on. Do you have a link or reference to anything exaplaining the breakage and why we should avoid it? If it's true, I may have quite a lot of work to do in the next little while...
Stephen M. Webb
Professional Free Software Developer
If you throw LD_LIBRARY_PATH into google, half the results on the first page are about how to set it, and the other half are explanations of why you shouldn't.
This is a good tutorial about libraries in Linux:
Static, Shared Dynamic and Loadable Linux Libraries
LD_LIBRARY_PATH - just say no
Why LD_LIBRARY_PATH is bad
Static, Shared Dynamic and Loadable Linux Libraries
Quote: Original post by BregmaQuote: Original post by Yezu
Isn't LD_LIBRARY_PATH broken, and should not be used?
I'm not aware of any such problem and we use it all the time in both commercial and free software products I work on. Do you have a link or reference to anything exaplaining the breakage and why we should avoid it? If it's true, I may have quite a lot of work to do in the next little while...
LD_LIBRARY_PATH - just say no
Why LD_LIBRARY_PATH is bad
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement