WINDOWS BINARY PACKAGE

In fulfillment of distribution requirements, the source code for GDAL/OGR 
and PROJ.4 together with the MSYS/MinGW built DLLs, header and other files
used in the building of the Windows binary package are available for download
from:

http://spatial.nhh.no/R/rgdal/

--------------------------------------------------------

Installing the R Windows binary rgdal package

In order to install the R Windows binary rgdal package, you should first have installed GDAL/OGR with all of their dependencies needed for the data you need to access. 

One way is to build PROJ.4, GDAL, and any extra libraries you require with MSYS and MinGW, ideally the same MinGW as is used to build R. In both cases configure, make, make install. Note the installation prefix and exit MSYS. Set an environment variable GDAL_HOME to that value in your R build console (Windows command line interface) --- the value will be passed through and used to access header files, libraries, and to copy across a DLL.

The MSYS build used here was proj 4.5.0 without jni, GDAL CVS 1.3.2+ dated October 2006, no external libraries.

--------------------------------

Alternative build approach:


Installing FWTools is a convenient way to get started (but will be limited to
the - extensive - range of drivers built into the binary package):

http://fwtools.maptools.org/

http://fwtools.maptools.org/windows-main.html

Setting the FWTools bin/ directory in the PATH environmental variable is
essential, (GDAL_DATA is set internally to the copy included in the rgdal
package).

The R Windows binary rgdal package can built against an FWTools Windows binary,
using VC++.


Notes:
###############################################################################
## Building rgdal binary against FWTools binary using VC++

MDSumner 30 April 2007

Windows XP2, SP2, .NET 2.0
Rtools in C:/R/Rtools.

Here I am using a 

	source install of R 2.5.0 in C:/R/Rsrc/R-2.5.0
	with a source install of sp 0.9-14, and 
	binary install of FWTools 1.2.2 in C:/FWTools.  

gdalinfo --version
GDAL 1.4.0.0, FWTools 1.2.2, released 2007/02/22

I have Visual C++ 2005, Express Edition.
http://msdn.microsoft.com/vstudio/express/visualc/download/
Version 8.0.50727.42  (RTM.050727-4200)


I obtain rgdal_0.5-9 source via CVS:

cvs -d:pserver:anonymous@rgdal.cvs.sourceforge.net:/cvsroot/rgdal login 
cvs -z3 -d:pserver:anonymous@rgdal.cvs.sourceforge.net:/cvsroot/rgdal co -P
rgdal

[R]/bin, [FWTools]/bin and [Rtools]/bin (as per standard R windows) are all in
the path.

1. Ensure you have Rdll.lib

## Build Rdll.lib and place in [R]\libs\ (see example below in link step, and
see
## 
http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/readme.packages.t
xt)

## [R]src\gnuwin32

make R.exp
lib /def:R.exp /out:Rdll.lib

2. Ensure the configure.win, Makefile.win and RGDAL.def are all correct. 



## set the location of GDAL_HOME in configure.win (mine is GDAL_HOME="C:/FWTools")
## Also change libgdal-1.dll to gdal_fw.dll in configure.win

Specifically, mine looks like this:

-//-- start configure.win

#!/bin/sh
if test -z "$GDAL_HOME" ; then
    GDAL_HOME="C:/FWTools"
fi
echo "GDAL_HOME=${GDAL_HOME}" > src/Makeconf.win

echo "using GDAL_HOME: ${GDAL_HOME}"

mkdir $DPKG/libs
cp ${GDAL_HOME}/bin/gdal_fw.dll $DPKG/libs

-//-- end configure.win


## [rgdal]/src  
##   - includes a Makefile.win with one line:   all:
##   - and RGDAL.def as supplied in rgdal/src

Place Makefile.win in src/, containing a single line:

all:


## run command window with VC++ (I can't see how else to include it in the path)
## First compile the C++ against R and FWTools include


3. Compile and link

cl /MT /Ox /EHsc /D "WIN32" /c /I C:/R/Rsrc/R-2.5.0/include /I C:/FWTools/include
*.cpp

## Then link the resulting files with R and gdal:
##  (note that this includes all the present .obj files, and the gdal_ and proj_ libs from GDAL_HOME

link /dll /out:rgdal.dll /def:rgdal.def *.obj C:\R\Rsrc\R-2.5.0\libs\Rdll.lib /libpath:"C:\FWTools\lib" gdal_i.lib proj_i.lib

4. Then build and install rgdal as normal.

R CMD build --binary rgdal

or (better)

R CMD INSTALL --build rgdal

to build a Windows binary package (zipfile)
or

R CMD INSTALL rgdal 

to install.

This step will fail if src/Makefile.win is not in place.

At this stage you will see errors if gdal_fw.dll (libgdal-1.dll) can't be found
(I don't know the difference, it seems to work)

R CMD INSTALL --library [path-to-[R]/library-of-choice] rgdal_[version#].tar.gz




------------------------------- Earlier notes (RSB)

Setting the FWTools bin/ directory in the PATH environmental variable is essential, (GDAL_DATA is set internally to the copy included in the rgdal package).

The R Windows binary rgdal package can built against an FWTools Windows binary, using VC++.

Notes:

Building rgdal.dll in rgdal/src:

Makefile.win with just all: on a single line.

cl /MT /Ox /EHsc /D "WIN32" /c /I E:\rsb\R\R-2.2.1pat\include /I C:\Programfiler\FWTools1.0.0a7\include *.cpp

link /dll /out:rgdal.dll /def:RGDAL.def gdal-bindings.obj ogr_geom.obj ogr_proj.obj ogrsource.obj E:\rsb\R\R-2.2.1pat\lib\Rdll.lib /libpath:"C:\Programfiler\FWTools1.0.0a7\lib" gdal_i.lib

for RSBs locations of current R and FWTools
