Search code examples
rlinuxdllcentosrgdal

Error loading rgdal


I have successfully installed the rgdal package along with the dependencies GDAL and Proj4. After installation I succesfully loaded the package in R with the library function. However after my most recent login when i type in the command library(rgdal) I get an error message:

Error: package or namespace load failed for 'rgdal' in dyn.load(file, 
DLLpath = DLLpath, ...):
unable to load shared object '/home/nikhail1/R/x86_64-pc-linux-gnu-
library/3.4/rgdal/libs/rgdal.so':
libgdal.so.20: cannot open shared object file: No such file or directory

I understand this means there is no link to the libgdal file but I am not sure how to fix it. libgdal.so.20 is in the system under /home/nikhail1/bin/gdal/lib/. The rgdal.so file is under the rgdal folder in the R library in my /home/nikhail1/ system. I do not have the authority to perform an ldconfig function on shared libraries (I am a novice). Does anyone have a function that could help me make the system recognize the pathway to libgdal.so.20. I am working on a Linux CentOs 6.9 system. I cannot perform any sudo apt-get, yum or brew functions.

Many thanks, Nikhail


Solution

  • You can set LD_LIBRARY_PATH to include /home/nikhail1/bin/gdal/lib, i.e. in bash

    export LD_LIBRARY_PATH="/home/nikhail1/bin/gdal/lib:$LD_LIBRARY_PATH"
    ldd /home/nikhail1/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs/rgdal.so
    

    should report libgdal.so.20 as been found. How to make this persistent depends on your desktop environment.