Take the 2-minute tour ×

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

2 Answers 2

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


