[R] rgdal under windows?

Roger Bivand Roger.Bivand at nhh.no
Thu Aug 19 20:27:03 CEST 2004


On Thu, 19 Aug 2004, Prof Brian Ripley wrote:

> On Thu, 19 Aug 2004, Benjamin Lloyd-Hughes wrote:
> 
> > Has anyone had any joy getting the rgdal package to compile under windows?
> 
> First you need to meet the system requirements:
> 
> SystemRequirements: GDAL library from 
> http://www.remotesensing.org/gdal/download.html
> 
> Since that has build instructions which say
> 
>   GDAL can be built on Windows using MS VC++ 6.x and MS Visual Studio .NET 
>   (C++) at the DOS command line.
> 
> you will first need to get a copy of DOS and those compilers.  (I suspect
> they mean the Windows command prompt, but they don't seem to know the
> difference which is not confidence-inspiring.  I also suspect they mean
> `or' not `and'.)  Then you will have to fathom out how to link against a
> VC++ DLL which since this C++ is very unlikely to work with MinGW.  So you
> probably need to make the package's rgdal.dll under VC++ -- see
> README.packages.
> 
> I have tried and failed to make GDAL with MinGW.
> 
> > I've been trying with MinGW using Duncan Murdoch's Rtools but to no avail.
> 
> Do read README.packages and follow the advice at the top.  You don't have 
> the (mis-attributed) tools in your path.  But that is probably the least 
> of your potential problems.
> 

Exactly. The closest anyone has got so far is Hisaji Ono, who used MSYS 
(http://www.mingw.org/) to build PROJ.4 and GDAL (GDAL depends on PROJ.4, 
PROJ.4 needs a PATH to metadata files for projection and transformation), 
and then hand-pasted the paths to the GDAL headers and library into 
src/Makevars, running Rcmd INSTALL rgdal at the Windows command prompt as 
usual. All of this can be repeated, but is not portable, and does not suit 
the very valuable standard binary package build system for Windows. 
Roughly:

1. Download everything you need to build source packages under Windows and 
make sure it works;

2. Download MSYS and make sure it works;

3. Download the GDAL and PROJ.4 source tarballs, and possibly other
libraries you want to use with GDAL, and *within MSYS* untar, ./configure
with the appropriate arguments, at least make but maybe also make install
- now leave MSYS;

4. Download the rgdal source package, and *at the Windows command prompt*
untar it, change the name of configure to something else, create
src/Makevars manually from src/Makevars.in, insert the correct values of:
PKG_CPPFLAGS as -I<path to the directory with the GDAL headers>, PKG_LIBS
as -L< ... GDAL libraries> -lgdal, run Rcmd INSTALL rgdal (better first 
Rcmd check rgdal), and repeat until all the problems are resolved.

5. The installation should work locally, but some paths are compiled into 
the resulting *.dll, so it will, most likely, not be portable.

Both Hisaji and I were surprised that this actually seemed to work (as of
late Autumn last year for the versions of MinGW and MSYS available then;  
further fragility is introduced by much of GDAL being written in C++); it
is not wholly impossible that it could be made available portably as a
Windows binary with an installer, but not through the regular R binary
package repositories.

> 

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




More information about the R-help mailing list