You are here

LD_LIBRARY_PATH

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 which cannot be provided automatically on DICE. However setting this globally - for example using bash's export command - is likely to break things in unpredictable ways.

LD_LIBRARY_PATH is a bash environment variable.

You should not generally export it into your environment because it will cause the library to be loaded globally instead of limiting it to the command you wish to influence. Instead use one of the following techniques. This will limit the influence of any loaded libraries. These 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 the command. 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, or you need to run a series of commands, or you 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.

Last reviewed: 
29/06/2022

System Status

Home dirs (AFS)
Network
Mail
Other services
University services
Scheduled downtime

Choose a topic