5

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?

elynnaie
  • 1,015
  • 3
  • 12
  • 16

2 Answers2

3

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

davidscolgan
  • 774
  • 2
  • 8
  • 14
  • 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. – elynnaie Sep 18 '12 at 14:25
2

Write a wrapper script.

#!/bin/bash

function my_directory
{
  olddir="$(pwd)"
  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"
$my_directory/relative/path/to/executable
ctrl-alt-delor
  • 2,326
  • 19
  • 29