[R] rgdal installation with two versions of GDAL

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 22 17:43:56 CEST 2015

On 22/04/2015 05:43, Rob Skelly wrote:
> Hello,
> I am using GDAL 2.0 for most of my work, but rgdal depends on GDAL < 2. I
> have built and installed GDAL 1.11.2 in /opt/gdal-1.11.2, and rgdal
> compiles and installs into R, using the following command:
> --configure-args="--with-gdal-config=/opt/gdal.1.11.2/bin/gdal-config"
> rgdal-0.9-2.tar.gz
> However when R attempts to load rgdal at the end of the installation, it
> fails with the error,
> Error in dyn.load(file, DLLpath = DLLpath, ...) :
>    unable to load shared object
> '/usr/local/lib/R/site-library/rgdal/libs/rgdal.so':
>    /usr/local/lib/R/site-library/rgdal/libs/rgdal.so: undefined symbol:
> _ZN10OGRPolygon7addRingEP13OGRLinearRing
> The addRing method on OGRPolygon seems to be a relic of GDAL 1.11.2 and no
> longer exists in 2.0, so R is loading libgdal from /usr/local/lib, not
> /opt/gdal-1.11.2/lib. I have confirmed this by temporarily moving the
> 1.11.2 libs into /usr/local, where it works fine.

You can *really* confirm where things are found via R CMD ldd ... see 
the manual.

> So, the question is, how to I convince R to use the new library search
> path? I'm on xubuntu, and R is installed using apt.

You either use the ld options when building rgdal.so (e.g. for your OS 
-Wl,-rpath=/opt/gdal-1.11.2/lib) or you link statically.  The latter is 
easier and safer ... just build a static GDAL.

Many projects set -R/-rpath flags in their config scripts: it is 
something you could suggest to the GDAL maintainers (and finding them is 
part of libtool which GDAL uses).

But (see the posting guide) the generic question belonged on R-devel and 
questions about rgdal on R-sig-geo.

> Thanks,
> Rob

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

More information about the R-help mailing list