[R-sig-Geo] rgdal on Mac OS X 3.9
Scott Mitchell
Scott_Mitchell at carleton.ca
Fri Sep 8 19:56:29 CEST 2006
On 8-Sep-06, at 03:12, Roger Bivand wrote:
> On Thu, 7 Sep 2006, Jonathan Boyd Thayn wrote:
>
>> I am trying to install the rgdal package on my Mac OS X 3.9. I have
>> installed the proj4 library and the GDAL library. I get the
>> following
>> error: How do I know where the GDAL libraries are located? What is
>> their path? Thanks.
>
> Could an OSX user please reply with help on how to find GDAL?
Depends on how you installed GDAL. There are Frameworks versions
available, there's the fink package manager, and there's the option
to compile from source yourself. Probably more options are available
too. How did you do it, Jonathan?
If you compiled and installed yourself, it's probably in the default
install location of /usr/local/bin/gdal-config, in which case you
probably just need to add /usr/local/bin to your PATH in the shell
you are using. For example, at the shell prompt, before starting R,
type
export PATH=$PATH:/usr/local/bin
to add that directory to the end of your path specification.
As long as the install can find the gdal-config program, that program
should be able to tell the build system where to find the libraries
and headers.
If you installed GDAL another way, you still need to figure out where
it has been installed - if it is a framework install, it's probably
in a subdirectory under /Library/Frameworks. If you can provide more
details of your install we can probably figure it out together.
> Could
> someone also comment on the viability of this OS version?
If I understand correctly, the binary downloads work only for OS
10.4.4 and up, but it should be possible to compile R from source on
10.3.9 -- again, that's IF I understand correctly.
>
> We have had user reports of success building rgdal from source on
> OSX, but
> I don't think the specific OS version(s) used are known - could OSX
> users
> please reply to this thread so that the list archives have a body of
> experience about this, please? The same applies to the way(s) in which
> GDAL and PROJ.4 were installed.
My answer to this got more complicated the more I delved into it. So
I've decided to document the full "transcript" here, in case it helps
others (or points out mistakes in my interpretations):
The machine I happen to be using at the moment appears to have R2.3.0
installed from the official Mac binary download site, with various
geo-related libraries added afterwards, including rgdal 0.4-3. I
haven't done updates on this machine for quite a while, and don't
know precisely what OS version was used when I did the installs, but
it would have been 10.4.something. It had GDAL 1.3.0 installed from
source into /usr/local, PROJ 4.4.x also from source in /usr/local.
That USED to work (so I've left the above text to document a
different combination of versions that used to work), but now I have
GDAL 1.3.1, and in my attempt to load the rgdal library I run into
trouble because it can't find a symbol. So I'm using this
opportunity to update my R.
To try to correspond to the original poster's situation a little more
closely, I'm compiling R from source instead of using the binaries.
Note, however, that I AM using OS 10.4.7 on a G5 machine with XCode
2.2.1 developer tools. The first FORTRAN compiler in my path is the
GNU g77, version 3.4.3, provided by Fink (fink.sf.net).
./configure without any arguments provided the following summary:
R is now configured for powerpc-apple-darwin8.7.0
Source directory: .
Installation directory: /Library/Frameworks
C compiler: gcc -g -O2 -std=gnu99
Fortran 77 compiler: gfortran -g -O2
C++ compiler: g++ -g -O2
Fortran 90/95 compiler: gfortran -g -O2
Interfaces supported: X11, aqua, tcltk
External libraries: readline, BLAS(generic), LAPACK(in blas)
Additional capabilities: PNG, JPEG, iconv, MBCS, NLS
Options enabled: framework, R profiling
Recommended packages: yes
Running make after that worked fine, but then since it upgraded the
existing R installation, my old extra packages are still in there. I
thought that I could make this work by reinstalling the packages that
use GDAL, and I came close, but ran into a new problem. If I
interpret correctly, when I first built R, it was for PPC only. Now
R tries to build universal binaries that can work on either PPC or
Intel chips, and I do have a build system that should handle this,
BUT some of my R packages are still leftover from the first build,
and I'm getting errors when it tries to build rgdal.
So, to fix that, I did:
sudo rm -rf /Library/Frameworks/R.framework
cd ~/src/R-2.3.1 (wherever your R source is, I had already done the
"make" step)
sudo make install
Then, from an R session started by root (you could also use R CMD
INSTALL):
install.packages(c("rgdal", "sp"), dependencies=TRUE, type="source")
and now the rgdal library successfully compiles and loads.
To put back some of the other packages I used to have installed, I
then did:
install.packages("ctv")
library("ctv")
install.views("Spatial")
That mostly worked, but complained about a couple of dependencies not
working, which is because some packages are only available as source
packages for Macs. The packages with errors were rgdal and VR.
Since I've already installed rgdal, I ignore that one, but for VR:
install.packages("VR", dependencies=TRUE, type="source")
And all looks good.
Hopefully all that might help someone trying to do something similar
in the future, even if it does diverge a bit from this initial post.
>
> Roger
Cheers,
Scott
>
----
Scott Mitchell, Assistant Professor, Carleton University
Department of Geography & Environmental Studies, Loeb B443A
& Geomatics and Landscape Ecology Research Laboratory, Nesbitt 340
Mailing: Loeb B349, 1125 Colonel By Dr., Ottawa, ON K1S 5B6 Canada
+1-613-520-2600 x2695 Fax: +1-613-520-4301 Scott_Mitchell at carleton.ca
More information about the R-sig-Geo
mailing list