Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-26-2004, 05:27 AM   #1
Registered: Jul 2004
Location: Spain
Posts: 111

Rep: Reputation: 20
Differences between LD_LIBRARY_PATH and LD_PRELOAD

Hello there, I would like to know what differences are between LD_LIBRARY_PATH and LD_PRELOAD enviroment variables. I know they are very similar, both are used by the linker.

Thanks In Advance
Old 05-12-2012, 07:51 PM   #2
LQ Newbie
Registered: Aug 2011
Posts: 5
Blog Entries: 1

Rep: Reputation: 1
Originally Posted by
The environment variable LD_LIBRARY_PATH is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories; this is useful when debugging a new library or using a nonstandard library for special purposes. The environment variable LD_PRELOAD lists shared libraries with functions that override the standard set, just as /etc/ does.
So (I think) LD_LIBRARY_PATH is used to add or replace a whole library object, and LD_PRELOAD is used to replace specific functions.

For example, my graphics card driver can't do 3D graphics, so I'm temporarily using llvmpipe for 3D applications (llvmpipe uses the CPU instead). As llvmpipe's version of the graphics library replaces the one that came with my graphics card driver (and is in the library search path by default), I add the directory to LD_LIBRARY_PATH:
LD_LIBRARY_PATH=/path/to/llvmpipe's/version/of/libGL:$LD_LIBRARY_PATH my3Dapp
By contrast, if I wanted to to replace the `puts' function (print a string to the standard output) of a program using the C standard library, I would write my own version of that function only, compile it to `' and do
LD_PRELOAD=/path/to/myputs/$LD_PRELOAD myConsoleApp
Then, whenever myConsoleApp used `puts', it would use the version compiled from my code and not the version in the file `' that it found and loaded.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
segmentation fault while defining LD_PRELOAD javeree Linux - Software 0 01-10-2005 03:48 PM
Differences between LD_LIBRARY_PATH and LD_PRELOAD Nerox Linux - Newbie 1 10-01-2004 08:03 AM
Ld_library_path fng_#1 Linux - Software 4 09-19-2004 11:33 PM
How do I make my shared loader ( understand LD_PRELOAD? ic3 Slackware 1 11-02-2003 06:57 AM
Ld_library_path ? dahmad Linux - Newbie 5 02-21-2003 11:08 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:58 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration