Reputation: 173
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
Upvotes: 3
Views: 4517
Reputation: 466
I've suffered quite a lot with gdal, rgdal and the proper setting of these in order to run rgdal functions in R. My bulletproof routine at the moment is the following:
UNINSTALL GDAL
sudo apt-get remove gdal-bin
Uninstall gdal-bin including dependent package
If you would like to remove gdal-bin and it's dependent packages which are no longer needed from Ubuntu,
sudo apt-get remove --auto-remove gdal-bin
Use Purging gdal-bin If you use with purge options to gdal-bin package all the configuration and dependent packages will be removed.
sudo apt-get purge gdal-bin
If you use purge options along with auto remove, will be removed everything regarding the package, It's really useful when you want to reinstall again.
sudo apt-get purge --auto-remove gdal-bin
Just to be sure if you've tried and failed many times to install it and it doesn't work, run all of these in sequential order.
INSTALL GDAL
sudo apt-get update
sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev -y
INSTALL RGDAL
IN R:
install.packages('rgeos', type='source')
install.packages('rgdal', type='source')
Now everything should load and run smooth.
Upvotes: 1
Reputation: 26823
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.
Upvotes: 6