Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

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.