0

I'm setting the environment variable LD_PRELOAD to a shared library file I created, in order to let LD_PRELOAD to point to my created shared library file, I need to give the full path like this:

export LD_PRELOAD=full/path/to/file.so

but if I point the LD_PRELOAD to a shared library under /usr/lib/, I don't need to give the full path, I don't have root privilege so I cannot put my shared library file to /usr/lib/, in such case, how can I set the environment variable LD_PRELOAD using non-fullpath like this:

 export LD_PRELOAD=file.so 
  • You could try adding the directory where the library lives to LD_LIBRARY_PATH? One way or another you're going to gave to give a full path somewhere, to tell the system how to locate your library. – Celada Mar 26 '15 at 23:59
0

The names listed in the LD_PRELOAD variable are looked up in $LD_LIBRARY_PATH, like library names mentioned in the executable itself. So if you want to preload /full/path/to/file.so, you can use

export LD_LIBRARY_PATH=/full/path/to
export LD_PRELOAD=file.so

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.