I am building an application using OpenGL. I have multiple OpenGL installed on a server.
I noticed that even after specifying link path for OpenGL
libraries at runtime in Makefile, when running the application it still looks for library in different places, resulting error.
The correct openGL
path is /usr/lib/nvidia-410/
yuqiong@sturfee-dnn:~/sturgRender/assets$ ls /usr/lib/nvidia-410/ | grep GL
libEGL_nvidia.so.0
libEGL_nvidia.so.410.129
libEGL.so
libEGL.so.1
libEGL.so.410.129
libGLdispatch.so.0
libGL.so
libGL.so.1
libGL.so.410.129
libGLX_indirect.so.0
libGLX_nvidia.so.0
libGLX_nvidia.so.410.129
libGLX.so
libGLX.so.0
libOpenGL.so
libOpenGL.so.0
However the LD_LIBRARY_PATH
points to :
yuqiong@sturfee-dnn:~/sturgRender/assets$ echo $LD_LIBRARY_PATH
/usr/local/torch/lib:/usr/local/tensorrt/lib:/usr/local/caffe/lib/:/usr/local/lib;//usr/local/cuda/lib64:/home/yuqiong/TensorRT-7.0.0.11/lib
This will cause the application to result in eglDisplayError
. However after changing LD_LIBRARY_PATH
to /usr/lib/nvidia-410/
, this error is gone.
I suspect this is because libEGL
and libGLX
and libOpenGL
is dynamically loaded.
However, on another machine, I build the application using CMake
, and even though LD_LIBRARY_PATH
is empty the application still links the correct libraries.
- Why do I need to specify
LD_LIBRARY_PATH
on one machine but not the other? - Is the information about where to load dynamic libraries stored in system variables like
LD_LIBRARY_PATH
, or in the application itself?