[R-sig-Geo] [R] Drawing Maps of detailed Australian regions

Roger Bivand Roger.Bivand at nhh.no
Fri Dec 17 13:25:38 CET 2010


On Fri, 17 Dec 2010, Jim Lemon wrote:

> On 12/17/2010 09:45 PM, Barry Rowlingson wrote:
>> ...
>>   The  error message is that libgdal.so cannot be found - this is the
>> GDAL C-level binary library, whereas
>> /usr/local/lib/R/library/rgdal/libs/rgdal.so is the R code that
>> interfaces to libgdal.so.
>>
>>   R tries to load rgdal.so, rgdal.so tries to load libgdal.so, can't
>> find it, fails.
>> 
>> Sadly it doesn't say where it's looking for it. Can you find
>> libgdal.so anywhere?
>> 
> Why of course:

NO!

On Unix/Linux, please read up about ldconfig, and make sure that the 
shared object is in the correct path (once you have a good understanding 
of ldconfig). You seem to be using a Windows tactic of placing an 
apparently missing DLL in an apparently visible directory. Doing it right 
is really easy, and always works unless one scatters multiple *.so around. 
You have multiple libgdal.so installed. You need to establish which one 
was the one rgdal.so was build against, and ensure that it is in the path. 
Then all of the remaining dependencies will fulfill automatically.

If you want to see what your rgdal.so depends on, do:

ldd rgdal.so

Then make sure that that/those directories are included in the path 
established by ldconfig (most will be, but /usr/lib/ogdi and
/home/jim/Download/FWTools-2.0.6/lib will not), or in an environment 
variable (set for example in your .bashrc) LD_LIBRARY_PATH. In general, 
binary installs should run ldconfig themselves, but you are - below - 
probably missing a symbolic link in /usr/lib, and appear to not to have 
installed the binaries satisfactorily.

I'm not sure from the thread that you explained how you installed rgdal, 
or whether you subsequently changed any of the things it depends on. For a 
clean install, do:

R CMD check rgdal_*.tar.gz

Complete the dependencies until it passes. Once it passes, you are good to 
go:

R CMD INSTALL rgdal_*.tar.gz

I think that your GDAL and PROJ4 installs are wrong/insufficient - for yum 
I would look for gdal, gdal-devel, proj, proj-devel, proj-nad, and 
possibly proj-epsg (see inst/README in the source package). Installing 
PROJ.4 and GDAL from source is often less trouble than handling multiple 
binaries, unless you set environment variable LD_LIBRARY_PATH, or use 
ldconfig, consistently, so that rgdal.so can "see" what it depends on. But 
do try to check with the source package first, because then the checked 
dependency routes should remain valid (until something is changed).

It is always sensible to run at least:

gdal-config --version
gdalinfo --version
proj -l

from the command line, to check that GDAL and PROJ4 utility programs find 
their own shared objects, and that the two gdal* commands report the same 
version.

Hope this helps,

Roger

>
> /home/jim/Download/FWTools-2.0.6/lib/libgdal.so
> /home/jim/Download/FWTools-2.0.6/lib/libgdal.so.1
> /home/jim/Download/FWTools-2.0.6/lib/libgdal.so.1.6.0
> /usr/lib/libgdal.so.1
> /usr/lib/libgdal.so.1.13.1
> /usr/lib/ogdi/libgdal.so
>
> So I copied the file to the same directory:
>
> cp /home/jim/Download/FWTools-2.0.6/lib/libgdal.so 
> /usr/local/lib/R/library/rgdal/libs
>
> and then got one step further:
>
> library(rgdal)
> Error in dyn.load(file, DLLpath = DLLpath, ...) :
>  unable to load shared library 
> '/usr/local/lib/R/library/rgdal/libs/rgdal.so':
>  libstdc++.so.5: cannot open shared object file: No such file or directory
> Error: package/namespace load failed for 'rgdal'
>
> So I copied that file to the same directory:
>
> cp /home/jim/Download/FWTools-2.0.6/lib/libstdc++.so.5 
> /usr/local/lib/R/library/rgdal/libs
>
> library(rgdal)
> Error in dyn.load(file, DLLpath = DLLpath, ...) :
>  unable to load shared library 
> '/usr/local/lib/R/library/rgdal/libs/rgdal.so':
>  libstdc++.so.5: cannot open shared object file: No such file or directory
> Error: package/namespace load failed for 'rgdal'
>
> and that's where I'm stuck. I really hope that it isn't this hard for 
> everyone who tries to use this package.
>
> Jim
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list