Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (3) </ 1 2 [3] >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: GTK2 dependencies< Next Oldest | Next Newest >
stupid_idiot Offline





Group: Members
Posts: 344
Joined: Oct. 2006
Posted: Jan. 06 2008,03:22 QUOTE

This is how I understand LD_LIBRARY_PATH works:
Linking of programs during compilation is done by the linker ('ld').
Loading of shared libraries at runtime is done by the loader ('/lib/ld-linux.so.2').
Note: '/lib/ld-linux.so.2' is typically a symlink to
'/lib/ld-[glibc_version].so'.
e.g. '/lib/ld-linux.so.2' -> '/lib/ld-2.3.2.so' (DSL uses glibc 2.3.2.)
(1) For example: We have an application called 'my_program' that needs some libraries in '/opt/compile-3.3.5/lib/'.
We can add LD_LIBRARY_PATH to the environment, and then run the application:
Code Sample
export LD_LIBRARY_PATH=/opt/compile-3.3.5/lib
my_program

Or, we can add LD_LIBRARY_PATH to the command line; it will take effect only for this command; it does not persist in the environment:
Code Sample
LD_LIBRARY_PATH=/opt/compile-3.3.5/lib my_program
or
Code Sample
my_program LD_LIBRARY_PATH=/opt/compile-3.3.5/lib

(3) Another method, that does not involve LD_LIBRARY_PATH, is to add '/opt/compile-3.3.5/lib/' to the ld.so cache file ('/etc/ld.so.cache'):
Code Sample
# Edit /etc/ld.so.conf:
editor /etc/ld.so.conf
# Run 'ldconfig' to rebuild '/etc/ld.so.cache' using the directories specified in '/etc/ld.so.conf':
ldconfig
# Run application:
my_program

Note: 'ldconfig' does not make use of LD_LIBRARY_PATH.
To test this, we could do the following, for example:
Code Sample

export LD_LIBRARY_PATH=/opt/compile-3.3.5/lib
ldconfig
# Then unset LD_LIBRARY_PATH:
unset LD_LIBRARY_PATH
# Then run the application:
my_program
(You will get an error.)
As this shows, in line 2, 'ldconfig' does NOT add '/whatever/' to '/etc/ld.so.cache'.
Thus, once we unset LD_LIBRARY_PATH in line 4, the library in '/whatever/' can no longer be found.
Conclusion: The only way to add a directory to '/etc/ld.so.cache' is to edit '/etc/ld.so.conf'.


Re: Linking
'ld' can use LD_LIBRARY_PATH to find libraries at link-time (such as '-liconv') in the same fashion as above.
(1) We can export LD_LIBRARY_PATH before running 'configure':
Code Sample
export LD_LIBRARY_PATH=/opt/compile-3.3.5/lib
./configure
make
LD_LIBRARY_PATH must not be unset until compilation is finished; otherwise, linking errors will occur because the linker cannot find needed libraries.
(1) Or, we can specify LDFLAGS when running 'configure':
Code Sample
LDFLAGS=-L/opt/compile-3.3.5/lib ./configure
We don't need to use LD_LIBRARY_PATH if we use LDFLAGS (but I am not sure about this...).

This TLDP page has relevant information (look for "LD_LIBRARY_PATH").
Back to top
Profile PM 
stupid_idiot Offline





Group: Members
Posts: 344
Joined: Oct. 2006
Posted: Jan. 16 2008,09:07 QUOTE

Rewrote the above post because it contained serious errors.
Very sorry for the misleading information!
The above post now has the correct information (hopefully!).
Back to top
Profile PM 
11 replies since Jan. 05 2008,11:44 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (3) </ 1 2 [3] >/
reply to topic new topic new poll
Quick Reply: GTK2 dependencies

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code