6

I am a novice in terms of using linux. According guides about my project I have to export multiple times LD_LIBRARY_PATH and I am not sure if I do not overwriting them.

#Cupti + Tensorflow_CUDAit
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64

#Mujoco
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/robolab/.mujoco/mujoco200/bin
export MUJOCO_PY_MJPRO_PATH=$HOME/.mujoco/mujoco200/
export MUJOCO_PY_MJKEY_PATH=$HOME/.mujoco/mjkey.txt

#Mujoco_py
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so

Is this the correct way or do I overwriting them? If so, what is to correct way?

Thank you in advance.

Darren Smith
  • 2,261
  • 16
  • 16
Sef Roboter
  • 61
  • 1
  • 1
  • 2
  • Possible duplicate of [How to set the environmental variable LD\_LIBRARY\_PATH in linux](https://stackoverflow.com/q/13428910/608639), [Why changing LD_LIBRARY_PATH has no effect in Ubuntu?](https://stackoverflow.com/q/47682750/608639), [Where is LD_LIBRARY_PATH? how do I set the LD_LIBRARY_PATH env variable?](https://unix.stackexchange.com/q/168340), [Modifying LD_LIBRARY_PATH](https://stackoverflow.com/q/27123663/608639), etc. – jww Nov 03 '19 at 12:44

1 Answers1

12

Your approach should work, i.e., you are adding several paths to LD_LIBRARY_PATH (rather than overwriting), however there are two pitfalls to watch out for.

(1) prefer to quote the LD_LIBRARY_PATH as in:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/home/robolab/.mujoco/mujoco200/bin

... so that embedded spaces within LD_LIBRARY_PATH does not cause a problem.

(2) Consider the order of putting the paths toegether, eg, you could alternatively do

export LD_LIBRARY_PATH=/home/robolab/.mujoco/mujoco200/bin:"$LD_LIBRARY_PATH"

If you experiment with both approaches and then echo $LD_LIBRARY_PATH you will see it changes the order of the paths, and this can be important if you have the same libraries in several locations.

Darren Smith
  • 2,261
  • 16
  • 16