skelley
skelley

Reputation: 63

Install R 'sf' package on Centos -- gdal shared library error

How can I install the R 'sf' package on CentOS? On attempting to install, I initially got an error due to an out of date gdal package; I updated gdal (built from source following: http://trac.osgeo.org/gdal/wiki/BuildingOnUnix) and now have an error:

 checking GDAL: linking with --libs only... yes
 checking GDAL: /usr/local/share/gdal/pcs.csv readable... yes
 checking GDAL: checking whether PROJ.4 is available for linking:... yes
 checking GDAL: checking whether PROJ.4 is available fur running:... 
 ./gdal_proj: error while loading shared libraries: libgdal.so.20: cannot open 
 shared object file: No such file or directory
  no
 configure: error: OGRCoordinateTransformation() does not return a 
coord.trans: 
 PROJ.4 not available?
ERROR: configuration failed for package ‘sf’

I've tried creating a symlink to libgdal.so.20, but this doesn't change the error at all.

Upvotes: 2

Views: 4598

Answers (3)

Santosh Garole
Santosh Garole

Reputation: 1956

@Dave has given exact steps & Please follow the below steps with some more explanation.

  1. Add /usr/local/lib to e.g. /etc/ld.so.conf.d/libgdal-x86_64.conf Please create the file libgdal-x86_64.conf if doesn't exists.

#echo "/usr/local/lib" >> /etc/ld.so.conf.d/libgdal-x86_64.conf

  1. Run ldconfig

#ldconfig

  1. Make sure you have GEOS,GDAL,PROJ installed on your system.

#yum install proj.x86_64 proj-devel.x86_64 proj-epsg.x86_64 proj-nad.x86_64 geos*

Try again

  1. Go to R cli & hit install.packages("sf")

Thanks hope this helps

Upvotes: 1

Wayne
Wayne

Reputation: 11

For anyone else who has a multi-user/multi-computer environment with the need to have multiple versions of various pieces of software installed, I fixed my issue with:

install.packages('sf',configure.args='--with-gdal-config=/sw/gdal/2.2.3-gcc4/bin/gdal-config --with-proj-include=/sw/proj/4.9.3-gcc4/include --with-proj-lib=/sw/proj/4.9.3-gcc4/lib --with-proj-share=/sw/proj/4.9.3-gcc4/share/proj')

Obviously you may/would have to alter path names from what I have.

Upvotes: 0

Dave Thom
Dave Thom

Reputation: 64

  1. Add /usr/local/lib to e.g. /etc/ld.so.conf.d/libgdal-x86_64.conf
  2. Run ldconfig
  3. Restart R
  4. Try again

Upvotes: 4

Related Questions