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,065

2 Answers2

3

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

dvcolgan
  • 824
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