Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed a binary and its dependencies to a non-standard location. When I run the binary, I need to specify the library locations of all its dependencies. I know one way of doing this is to do:

export LD_LIBRARY_PATH="/path/to/shared/libraries:/path/to/more/shared/libraries"

...but this seems hackish, in that I'll need to put this in every user's .bashrc who intends to run the program. Without installing the libs to a system directory, is there a better way of ensuring that the binary is always able to link to the correct libs?

share|improve this question
up vote 3 down vote accepted

You can put this line in /etc/profile and it will apply to all user accounts.

share|improve this answer
This seems to work only for login shells. Since I want it to run every time I start bash, I instead put it in my /etc/bash.bashrc so that it fires for every bash shell. – denaje Sep 18 '12 at 14:25

Write a wrapper script.


function my_directory
  cd "$(dirname $0)"
  echo "$(pwd)"
  cd "$olddir"

export LD_LIBRARY_PATH="$my_directory/relative/path/to/shared/libraries:$my_directory/relative//path/to/more/shared/libraries"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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