You are here


Printer-friendly versionPrinter-friendly version

Sometimes a software guide will tell you to set LD_LIBRARY_PATH to a certain value. This is occasionally required by certain pieces of software (for example to load a library cannot be provided automatically on DICE) but setting this value globally (for example using the export command) is likely to break things in unpredictable ways.

LD_LIBRARY_PATH is an example of a bash environment variable. Using export will cause the library to be loaded globally instead of limiting it to the command you wish to influence. Rather than following common installation instructions we advise one of the following techniques to limit the influence of any loaded libraries. The following examples show how to set LD_LIBRARY_PATH so that its new value (here /my/strange/lib/path) is only visible to the (fictitious) command embiggen, leaving other software working as normal.

In-place assignment

If you only need the library for a single, simple command it might be easiest to simply declare it when you run, for example (where /my/strange/lib/path is the location of the .so file(s) needed):

LD_LIBRARY_PATH=/my/strange/lib/path embiggen smallfile

Bash function

If you need to run the command in a variety of ways, need to run a series of commands or just don't want to forget to include the variable you could set it inside a bash function:

function mybig {(export LD_LIBRARY_PATH=/my/strange/lib/path; embiggen $*)}

Once defined, running the command mybig would set LD_LIBRARY_PATH appropriately, then run the command embiggen, adding whatever other parameters you added to the command line too. For example, mybig one two three would run the command embiggen one two three with the correct LD_LIBRARY_PATH setting.

To save your function for later, add it to a bash startup file such as ~/.benv. Remember that bash startup files have unique names on DICE - see How does the DICE bash start-up mechanism work? for details. See bash for an introduction to bash and its documentation.

Last reviewed: 

System Status

Home dirs (AFS)
Other services
Scheduled downtime

Choose a topic