Rev 17481 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<html lang="en"><head><title>R Installation and Administration</title><meta http-equiv="Content-Type" content="text/html"><meta name=description content="R Installation and Administration"><meta name=generator content="makeinfo 4.0b"><link href="http://texinfo.org/" rel=generator-home></head><body><a name="Top"></a><h1>R Installation and Administration</h1><p>This is a guide to installation and administration for R.<p>The current version of this document is 1.4.1 (2002-01-30).</ul><a name="Obtaining%20R"></a><h1>1 Obtaining R</h1><p>Sources, binaries and documentation for R can be obtained via<small>CRAN</small>, the "Comprehensive R Archive Network". See the file<code>RESOURCES</code> for information on <small>CRAN</small>.</ul><a name="Getting%20and%20unpacking%20the%20sources"></a><h2>1.1 Getting and unpacking the sources</h2><p>The simplest way is to download the most recent<code>R-<var>x</var>.<var>y</var>.<var>z</var>.tgz</code> file, and unpack it with<pre>tar xvfz R-<var>x</var>.<var>y</var>.<var>z</var>.tgz</pre><p>on systems that have GNU <code>tar</code> installed. On other systems youneed at least to have the <code>gzip</code> program installed. Then youcan use<pre>gzip -dc R-<var>x</var>.<var>y</var>.<var>z</var>.tgz | tar xvf -</pre><p>If you need to transport the sources on floppy disks, you can downloadthe <code>R-<var>x</var>.<var>y</var>.<var>z</var>.tgz-split.*</code> files and paste themtogether at the destination with (Unix)<pre>cat R-<var>x</var>.<var>y</var>.<var>z</var>-split.* > R-<var>x</var>.<var>y</var>.<var>z</var>.tgz</pre><p>and proceed as above. If you want the build to be usable by a group ofusers, set <code>umask</code> before unpacking so that the files will bereadable by the target group (e.g., <code>umask 022</code> to be usable by allusers).<p>Finally, for minor-minor releases (<code><var>x</var>.<var>y</var>.<var>z</var></code> with<var>z</var> != 0), a patch against the preceding release is made availablein<code>R-<var>x</var>.<var>y</var>.<var>{z-1}</var>-<var>x</var>.<var>y</var>.<var>z</var>.diff.gz</code>(e.g., <code>R-1.2.2-1.2.3.diff.gz</code>), which is generally a much smallerfile that the <code>.tgz</code> files. Such a file can be applied to thesources of the previous version by changing to the top directory of itand<pre>gzip -dc /path/to/it/R-<var>x</var>.<var>y</var>.<var>{z-1}</var>-<var>x</var>.<var>y</var>.<var>z</var>.diff.gz | patch -E -p1</pre><p>Beware that this does not necessarily work if the older sources havebeen modified (e.g., by building in their directories).<a name="Using%20rsync"></a><h2>1.2 Using rsync</h2><p>Sources are also available via anonymous rsync. Use<pre>rsync -rC rsync.r-project.org::<var>module</var> R</pre><p>to create a copy of the source tree specified by <var>module</var> in thesubdirectory <code>R</code> of the current directory, where <var>module</var>specifies one of the four existing flavors of the R sources, and can beone of <code>r-release</code> (current released version), <code>r-patched</code>(patched released version), and <code>r-devel</code> (development version,less stable), and <code>r-ng</code> (next generation, unstable). The rsynctrees are created directly from the master CVS archive and are updatedhourly. The <code>-C</code> option in the <code>rsync</code> command is tocause it to skip the CVS directories. Further information on<code>rsync</code> is available at <a href="http://rsync.samba.org/rsync/">http://rsync.samba.org/rsync/</a>.<a name="Installing%20R%20under%20Unix"></a><h1>2 Installing R under Unix</h1><p>R will configure and build from source under a number of commonUnix-like platforms, including <code>i386-freebsd</code>,<code>i386-linux-gnu</code>, <code>i386-sun-solaris</code>,<code>powerpc-linux-gnu</code>, <code>powerpc-apple-darwin</code>,<code>mips-sgi-irix</code>, <code>alpha-linux-gnu</code>, <code>alpha-dec-osf4</code>,<code>rs6000-ibm-aix</code>, <code>hppa-hp-hpux</code>, <code>sparc-linux-gnu</code> and<code>sparc-sun-solaris</code>.<p>In addition, binary distributions are available for most common Linuxdistributions, Compaq Alpha systems running OSF/Tru64, and for MacOS X(Darwin) with X11. See the <small>FAQ</small> for current details. Theseare installed in platform-specific ways. So for the rest of thischapter we consider only building from the sources.</ul><a name="Simple%20compilation"></a><h2>2.1 Simple compilation</h2><p>First review the essential and useful tools and libraries in<a href="#Essential%20and%20useful%20other%20programs">Essential and useful other programs</a>, and install those you want orneed.<p>Choose a place to install the R tree (R is not just a binary, buthas additional data sets, help files, font metrics etc). Let us callthis place <code>R_HOME</code>. Untar the source code. This should createdirectories <code>src</code>, <code>doc</code>, and several more. Issue thefollowing commands:<pre>./configuremake</pre><p>(See <a href="#Using%20make">Using make</a> if your make is not called <code>make</code>.)<p>Then check the built system works correctly, by<pre>make check</pre><p>Failures are not necessarily problems as they might be caused by missingfunctionality, but you should look carefully at any reporteddiscrepancies. To re-run the tests you would need<pre>make check FORCE=FORCE</pre><p>If these commands execute successfully, the R binary will be copiedto the <code>${R_HOME}/bin</code> directory. In addition, a shell-scriptfront-end called <code>R</code> will be created and copied to the samedirectory. You can copy this script to a place where users can invokeit, for example to <code>/usr/local/bin/R</code>. You could also copy the manpage <code>R.1</code> to a place where your <code>man</code> reader finds it,such as <code>/usr/local/man/man1</code>. If you want to install the completeR tree to, e.g., <code>/usr/local/lib/R</code>, see <a href="#Installation">Installation</a>.Note: you do not <em>need</em> to install R: you can run it from whereit was built.<p>You do not necessarily have to build R in the top-level sourcedirectory (say, <code><var>TOP_SRCDIR</var></code>). To build in<code><var>BUILDDIR</var></code>, run<pre>cd <var>BUILDDIR</var><var>TOP_SRCDIR</var>/configuremake</pre><p>and so on, as described further below. This has the advantage of alwayskeeping your source tree "clean". (You may need GNU <code>make</code> toallow this.)<p>Make will also build plain text help pages as well as <small>HTML</small> andLaTeX versions of the R object documentation (the three kinds canalso be generated separately using <code>make help</code>, <code>make html</code>and <code>make latex</code>). Note that you need Perl version 5: if this isnot available on your system, you can obtain PDF versions of thedocumentation files via <small>CRAN</small>.<p>Now <code>rehash</code> if necessary, type <kbd>R</kbd>, and read the R manualsand the R <small>FAQ</small> (files <code>FAQ</code> or<code>doc/html/faq.html</code>, or<a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html">http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html</a> which always hasthe latest version).<a name="Making%20the%20manuals"></a><h2>2.2 Making the manuals</h2><p>There is a set of manuals that can be built from the sources,<dl><dt><code>refman</code><dd>Printed versions of all the help pages.<br><dt><code>R-FAQ</code><dd>R <small>FAQ</small> (which is already built for you).<br><dt><code>R-intro</code><dd>"An Introduction to R".<br><dt><code>R-data</code><dd>"R Data Import/Export".<br><dt><code>R-admin</code><dd>"R Installation and Administration", this manual.<br><dt><code>R-exts</code><dd>"Writing R Extensions".<br><dt><code>R-lang</code><dd>"The R Language Definition".</dl><p>To make these, use<pre>make dvi to create DVI versionsmake pdf to create PDF versionsmake info to create info files (not <code>refman</code>).</pre><p>You will not be able to build the info files unless you have<code>makeinfo</code> version 4 or later installed (and some Linuxdistributions have 3.12).<p>The DVI versions can be previewed and printed using standard programssuch as <code>xdvi</code> and <code>dvips</code>. The PDF versions can beviewed using Acrobat Reader or (recent versions of) ghostscript: theyhave hyperlinks that can be followed in Acrobat Reader. The info filesare suitable for reading online with Emacs or the standalone GNU Info.<a name="Installation"></a><h2>2.3 Installation</h2><p>After<pre>./configuremakemake check</pre><p>have been completed successfully, you can install the complete R treeto your system by typing<pre>make install</pre><p>This will install to the following directories:<dl><dt><code>${prefix}/bin</code><dd>the front-end shell script<br><dt><code>${prefix}/man/man1</code><dd>the man page<br><dt><code>${prefix}/lib/R</code><dd>all the rest (libraries, on-line help system, <small>...</small>)</dl><p>where <code>prefix</code> is determined during configuration (typically<code>/usr/local</code>) and can be set by running <code>configure</code> withthe option <code>--prefix</code>, as in<pre>./configure --prefix=/where/you/want/R/to/go</pre><p>This causes <code>make install</code> to install the R executable to<code>/where/you/want/R/to/go/bin</code>, and so on. The prefix of theinstallation directories can be seen in the status message that isdisplayed at the end of <code>configure</code>. You can install intoanother directory by using<pre>make prefix=/path/to/here install</pre><p>To install DVI, info and PDF versions of the manuals, use one or more of<pre>make install-dvimake install-infomake install-pdf</pre><p>To ensure that the installed tree is usable by the right group of users,set <code>umask</code> appropriately (perhaps to <code>022</code>) before unpackingthe sources and throughout the build process.<a name="Installing%20R%20under%20Windows"></a><h1>3 Installing R under Windows</h1><p>The <code>bin/windows</code> directory of a <small>CRAN</small> site containsbinaries for a base distribution and a large number of add-on packagesfrom <small>CRAN</small> to run on Windows 95, 98, NT4, 2000 and ME (atleast) on Intel and clones (but not on other platforms).<p>You do need one of those Windows versions: Windows 3.11+win32s will notwork.<p>Your file system must allow long file names (as is likely exceptperhaps for some network-mounted systems).<p>The simplest way is to use <code>SetupR.exe</code> or <code>miniR.exe</code>. Justdouble-click on the icon and follow the instructions. If you installedR this way you can uninstall it from the Control Panel or Start Menu(unless you suppressed making a group for R).<p>See the <a href="http://www.stats.ox.ac.uk/pub/R/rw-FAQ.html">R Windows <small>FAQ</small></a> for more details.</ul><a name="Building%20from%20source"></a><h2>3.1 Building from source</h2><p>If you want to build this port from the sources, see the file<code>src/gnuwin32/INSTALL</code> in the source distribution. You will needto collect, install and test an extensive set of tools: see<a href="http://www.stats.ox.ac.uk/pub/Rtools/">http://www.stats.ox.ac.uk/pub/Rtools/</a> for the current locations.<p>You may need to compile under a case-honouring file system: we foundthat a <code>samba</code>-mounted file system (which maps all file names tolower case) did not work. Open a commands window at a directory whosepath does not contain spaces, and run something like<pre>tar zxvf R-1.3.0.tgzcd R-1.3.0\src\gnuwin32make</pre><p>sit back and wait (for about 5 minutes on 1GHz PIII with a fast localdisc).<p>For further details, including how to make the documentation and how tocross-compile, see <code>src/gnuwin32/INSTALL</code>.<a name="Installing%20R%20on%20Classic%20MacOS"></a><h1>4 Installing R on Classic MacOS</h1><p>The <code>bin/macos</code> directory of a <small>CRAN</small> site contains<code>bin-hex</code>ed (<code>hqx</code>) and <code>stuffit</code> (<code>sit</code>)archives for a base distribution and a large number of add-on packagesto run under MacOS 8.6 to MacOS 9.1 or MacOS X natively. Just extractone of these archives in a suitable folder using standard utilities likeAladdin Stuffit Expander (tm).<p>There is also a port to MacOS X which is considered to be a Unix variantin this document. You can find it in the <code>bin/macosx</code> directory atof a <small>CRAN</small> site.<a name="Add-on%20packages"></a><h1>5 Add-on packages</h1></ul><p>This chapter applies to Unix-like and Windows versions of R, but notto the Classic MacOS port.<p>It is helpful to use the correct terminology. A <em>package</em> isloaded from a <em>library</em> by the function <code>library</code>. Thus alibrary is a directory containing installed packages; the main libraryis <code>R_HOME/library</code>, but others can be used, for example by settingthe environment variable <code>R_LIBS</code> or using the R function<code>.libPaths()</code>.<a name="Installing%20packages"></a><h2>5.1 Installing packages</h2><p>Note that you need to specify implicitly or explicitly the library towhich the package is to be installed. This is only an issue if you havemore than one library, of course.<p>To install packages from source on Unix use<pre>R CMD INSTALL -l /path/to/library <var>pkg1</var> <var>pkg2</var> <small>...</small></pre><p>The part <code>-l /path/to/library</code> can be omitted, when the firstlibrary in <code>R_LIBS</code> is used if set, otherwise the main library<code>R_HOME/library</code>.<p>The Windows equivalent is<a rel=footnote href="#fn-1"><sup>1</sup></a><pre>Rcmd INSTALL -l /path/to/library <var>pkg1</var> <var>pkg2</var> <small>...</small></pre><p>Alternatively, packages can be downloaded and installed from withinR. First set the option <code>CRAN</code> to your nearest <small>CRAN</small>mirror, for example<pre>> options(CRAN = "http://cran.us.r-project.org/")</pre><p>Then download and install package <strong>foo</strong> by<pre>> install.packages("foo")</pre><p>Unless the library is specified (argument <code>lib</code>) the first libraryin the library search path is used.<p>What this does is different on Unix and Windows. On Unix it consultsthe list of available source packages on <small>CRAN</small>, downloads thelatest version of the <strong>foo</strong> sources, and installs it (via <code>RCMD INSTALL</code>). On Windows it looks at the list of <em>binary</em>versions of packages and downloads the latest version (if any).<p>On Windows <code>install.packages</code> can also install a binary packagefrom a local <code>zip</code> file by setting argument <code>CRAN</code> to<code>NULL</code>. <code>RGui.exe</code> has a menu <code>Packages</code> with a GUIinterface to <code>install.packages</code>, <code>update.packages</code> and<code>library</code>.<a name="Updating%20packages"></a><h2>5.2 Updating packages</h2><p>The command <code>update.packages()</code> is the simplest way to ensure thatall the packages on your system are up to date. Set the <code>CRAN</code>option as in the previous section. The <code>update.packages()</code>downloads the list of available packages and their current versions,compares it with those installed and offers to fetch and install anythat have later versions on <small>CRAN</small>.<p>An alternative way of keeping packages up-to-date is provided by thecommand <code>packageStatus()</code>, which returns an object with informationon all installed packages and packages available at multiplerepositories (CRAN, local archive, <small>...</small>). The <code>print</code> and<code>summary</code> methods give an overview of installed and availablepackages, the <code>upgrade</code> method offers to fetch and install outdatedpackages. This allows R to fetch packages from several repositories andkeep in sync with all of them, instead of only one CRAN mirror, and isintended to become the default package manager for future versions of R.<a name="Removing%20packages"></a><h2>5.3 Removing packages</h2><p>Packages can be removed in a number of ways. From a command prompt theycan be removed by<pre>R CMD REMOVE -l /path/to/library <var>pkg1</var> <var>pkg2</var> <small>...</small></pre><p>(Unix) or<pre>Rcmd REMOVE -l /path/to/library <var>pkg1</var> <var>pkg2</var> <small>...</small></pre><p>(Windows).<p>From a running R process they can be removed by<pre>> remove.packages(c("pkg1", "pkg2"),lib = file.path("path", "to", "library"))</pre><p>Finally, in most installations one can just remove the package directoryfrom the library.<a name="Essential%20and%20useful%20other%20programs"></a><h1>Appendix A Essential and useful other programs</h1><p>This appendix gives details of programs you will need to build R onUnix-like platforms, or which will be used by R if found by<code>./configure</code>.</ul><a name="Essential%20programs"></a><h2>A.1 Essential programs</h2><p>You need a means of compiling C and FORTRAN (see <a href="#Using%20FORTRAN">Using FORTRAN</a>).Some add-on packages also need a C++ compiler.<p>You will need Perl version 5, available via<a href="http://www.perl.com/CPAN/">http://www.perl.com/CPAN/</a>, to build any of the on-linedocumentation.<p>You will not be able to build the info files unless you have<code>makeinfo</code> version 4 or later installed (and some Linuxdistributions have 3.12).<p>The typeset documentation needs <code>tex</code> and <code>latex</code>, or<code>pdftex</code> and <code>pdflatex</code>.<a name="Useful%20libraries%20and%20programs"></a><h2>A.2 Useful libraries and programs</h2><p>The command-line editing depends on the <code>readline</code> libraryavailable from any GNU mirror: you will need a fairly recent version.<p>Use of <code>gzfile</code> connections needs <code>zlib</code> (version 1.1.3 or later).<p>The bitmapped graphics devices <code>jpeg()</code> and <code>png()</code> need theappropriate libraries installed: <code>jpeg</code> (version 6b or later) or<code>libpng</code> (version 1.0.5 or later)and <code>zlib</code> (version 1.1.3 or later) respectively.<p>The <code>bitmap</code> and <code>dev2bitmap</code> devices make use of ghostscript(<a href="http://www.cs.wisc.edu/~ghost">http://www.cs.wisc.edu/~ghost</a>).</ul><a name="Tcl%2fTk"></a><h3>A.2.1 Tcl/Tk</h3><p>The <strong>tcltk</strong> package needs Tcl/Tk installed: the sources areavailable at <a href="http://dev.scriptics.com/">http://dev.scriptics.com/</a>. To specify the locationsof the Tcl/Tk files you may need the configuration options<dl><dt><code>--with-tcltk</code><dd>use Tcl/Tk, or specify its library directory<br><dt><code>--with-tcl-config=<var>TCL_CONFIG</var></code><dd>specify location of <code>tclConfig.sh</code><br><dt><code>--with-tk-config=<var>TK_CONFIG</var></code><dd>specify location of <code>tkConfig.sh</code></dl><a name="Linear%20algebra"></a><h3>A.2.2 Linear algebra</h3><p>The linear algebra routines in R can make use of enhanced BLAS (BasicLinear Algebra Subprograms, <a href="http://www.netlib.org/blas/faq.html">http://www.netlib.org/blas/faq.html</a>)routines. Some are compiler-system-specific (<code>libsunperf</code> on SunSparc<a rel=footnote href="#fn-2"><sup>2</sup></a>, <code>libessl</code> on IBM) but ATLAS(<a href="http://www.netlib.org/atlas/">http://www.netlib.org/atlas/</a>) is a `tuned' BLAS that runs on awide range of Unix-alike platforms. If no more specific library isfound, a <code>libblas</code> library in the library path will be used. Youcan specify a specific BLAS library by the configuration option<code>--with-blas</code> and not to use an external BLAS library by<code>--without-blas</code>.<p>Note that the BLAS library will be used for several add-on packages aswell as for R itself. This means that it is better to use a sharedBLAS library, as most of a static library will be compiled into the Rexecutable and each BLAS-using package.<p>You will need double-precision and double-complex versions of the BLAS,but not single-precision nor complex routines.<p>Optimized versions of LAPACK are available, but no provision is made forusing them with R as the likely performance gains are thought to besmall.<p>As with all libraries, you need to ensure that they and R werecompiled with compatible compilers and flags. For example, this meansthat on Sun Sparc using the native compilers the flag <code>-dalign</code>is needed so <code>libsunperf</code> can be used.<p>An ATLAS `tuned' BLAS can also be used on Windows: see<code>src/gnuwin32/INSTALL</code> for how to enable this.<p>Note that if R is compiled against a non-default BLAS, then allBLAS-using packages must also be. So if R is re-built after ATLAS isinstalled, then packages such as <strong>quantreg</strong> will need to bere-installed.<a name="Configuration%20on%20Unix"></a><h1>Appendix B Configuration on Unix</h1></ul><a name="Configuration%20options"></a><h2>B.1 Configuration options</h2><p><code>configure</code> has many options: running<pre>./configure --help</pre><p>will give a list. Probably the most important ones not coveredelsewhere are (defaults in brackets)<dl><dt><code>--with-x</code><dd>use the X Window System<br><dt><code>--x-includes=<var>DIR</var></code><dd>X include files are in <var>DIR</var><br><dt><code>--x-libraries=<var>DIR</var></code><dd>X library files are in <var>DIR</var><br><dt><code>--with-readline</code><dd>use readline library (if available) [yes]<br><dt><code>--enable-R-profiling</code><dd>attempt to compile support for <code>Rprof()</code> [yes]<br><dt><code>--enable-R-shlib</code><dd>build R as a shared library [no]</dl><p>You can use <code>--without-foo</code> or <code>--disable-foo</code> for thenegatives.<p>You will want to use <code>--disable-R-profiling</code> if you are buildinga profiled executable of R (e.g. with <code>-pg)</code>.<p>Flag <code>--enable-R-shlib</code> causes the make process to build R as ashared library, typically called <code>libR.so</code>, and to takeconsiderably longer, so you probably only want this if you will be usingan application which embeds R.<a name="Configuration%20variables"></a><h2>B.2 Configuration variables</h2><p>If you need or want to set certain configure variables to somethingother than their default, you can do that by either editing the file<code>config.site</code> (which documents all the variables you might want toset) or on the command line as<pre>VAR="..." ./configure # Bourne shell compatibles(setenv VAR "..."; ./configure) # C shell</pre><p>One common variable to change is <code>R_PAPERSIZE</code>, which defaults to<code>a4</code>, not <code>letter</code>.<p>If you have libraries and header files, e.g., for GNU readline, innon-system directories, use the variables <code>LIBS</code> (for libraries)and <code>CPPFLAGS</code> (for header files), respectively, to specify theselocations. These default to <code>/usr/local/lib</code> and<code>/usr/local/include</code> to catch the most common cases. If librariesare still not found, then maybe your compiler/linker does not supportre-ordering of <code>-L</code> and <code>-l</code> flags (this has been reportedto be a problem on HP-UX with the native <code>cc</code>). In this case,use a different compiler (or a front end shell script which does there-ordering).<p>If you find you need to alter configure variables, it is worth notingthat some settings are cached in the file <code>config.cache</code>, and it isa good idea to remove that file before re-configuring.<a name="Using%20make"></a><h2>B.3 Using make</h2><p>To compile R, you will most likely find it easiest to use GNU<code>make</code>. On Solaris 2.6/7/8 in particular, you need a version ofGNU <code>make</code> different from 3.77; 3.79 works fine, as does the Sun<code>make</code>. The native <code>make</code> is reported to fail on SGIIrix 6.5.<p>To build in a separate directory you need a <code>make</code> that uses the<code>VPATH</code> variable, for example GNU <code>make</code>, or Sun<code>make</code> on Solaris 2.7/8 (but not earlier).<p>If you want to use a <code>make</code> by another name, for example if yourGNU <code>make</code> is called <code>gmake</code>, you need to set theenvironment variable <code>MAKE</code> at configure time, for example<pre>MAKE=gmake ./configure (sh, bash)env MAKE=gmake ./configure (csh)</pre><a name="Using%20FORTRAN"></a><h2>B.4 Using FORTRAN</h2><p>To compile R, you need a FORTRAN compiler or <code>f2c</code>, theFORTRAN-to-C converter (<a href="http://www.netlib.org/f2c">http://www.netlib.org/f2c</a>). The defaultis to search for <code>g77</code>, <code>f77</code>, <code>xlf</code>,<code>cf77</code>, <code>cft77</code>, <code>pgf77</code>, <code>fl32</code>,<code>af77</code>, <code>fort77</code>, <code>f90</code>, <code>xlf90</code>,<code>pgf90</code>, <code>epcf90</code>, <code>f95</code>, <code>xlf95</code>,<code>lf9</code>5, <code>g95</code>, and <code>fc</code> (in thatorder)<a rel=footnote href="#fn-3"><sup>3</sup></a>, andthen for <code>f2c</code>, and use whichever is found first; if none isfound, R cannot be compiled. The search mechanism can be changedusing the <code>--with-g77</code>, <code>--with-f77</code>, and<code>--with-f2c</code> command line options to <code>configure</code>. Ifyour FORTRAN compiler is in a non-standard location, you should set theenvironment variable <code>PATH</code> accordingly before running<code>configure</code>.<p>If your FORTRAN libraries are in slightly peculiar places, you shouldalso look at <code>LD_LIBRARY_PATH</code> or your system's equivalent to makesure that all libraries are on this path.<p>You must set whatever compilation flags (if any) are needed to ensurethat FORTRAN <code>integer</code> is equivalent to a C <code>int</code> pointer andFORTRAN <code>double precision</code> is equivalent to a C <code>double</code>pointer. This is checked during the configuration process.<p>Some of the FORTRAN code makes use of <code>COMPLEX*16</code> variables, whichis a FORTRAN 90 extension. This is checked for at configuretime<a rel=footnote href="#fn-4"><sup>4</sup></a>, but you may need to avoidcompiler flags<a rel=footnote href="#fn-5"><sup>5</sup></a> assertingFORTRAN 77 compliance.<p>For performance reasons<a rel=footnote href="#fn-6"><sup>6</sup></a> you may want to choose a FORTRAN 90/95 compiler.<p>If you use <code>f2c</code> you may need to ensure that the FORTRAN type<code>integer</code> is translated to the C type <code>int</code>. Normally<code>f2c.h</code> contains <code>typedef long int integer;</code>, which willwork on a 32-bit platform but not on a 64-bit platform.<a name="Compile%20and%20load%20flags"></a><h2>B.5 Compile and load flags</h2><p>A wide range of flags can be set in the file <code>config.site</code> or viaenvironment variables. We have already mentioned<dl><dt><code>CPPFLAGS</code><dd>extra include flags<br><dt><code>LIBS</code><dd>libraries and <code>-L/lib/path</code> flags</dl><p>and others include<dl><dt><code>CFLAGS</code><dd>debugging and optimization flags, C<br><dt><code>MAIN_CFLAGS</code><dd>ditto, for compiling the main program<br><dt><code>SHLIB_CFLAGS</code><dd>for shared libraries<br><dt><code>FFLAGS</code><dd>debugging and optimization flags, FORTRAN<br><dt><code>MAIN_FFLAGS</code><dd>ditto, for compiling the main program<br><dt><code>SHLIB_FFLAGS</code><dd>for shared libraries<br><dt><code>MAIN_LDFLAGS</code><dd>additional flags for the main link<br><dt><code>SHLIB_LDFLAGS</code><dd>additional flags for linking the shared libraries</dl><p>Library paths specified as <code>-L/lib/path</code> in <code>LIBS</code> arecollected together and prepended to <code>LD_LIBRARY_PATH</code> (or yoursystem's equivalent), so there should be no need for <code>-R</code> or<code>-rpath</code> flags.<p>To compile a profiling version of R, one might for example want touse <code>MAIN_CFLAGS=-pg</code>, <code>MAIN_FFLAGS=-pg</code>,<code>MAIN_LDFLAGS=-pg</code> on platforms where <code>-pg</code> cannot be usedwith position-independent code.<p><strong>Beware:</strong> it may be necessary to set <code>CFLAGS</code> and<code>FFLAGS</code> in ways compatible with the libraries to be used: onepossible issue is the alignment of doubles, another is the waystructures are passed.<a name="Building%20the%20GNOME%20interface"></a><h2>B.6 Building the <small>GNOME</small> interface</h2><p>This interface is experimental and incomplete. It provides a consoleand two graphics devices named <code>gtk()</code> and <code>gnome()</code>. Theconsole offers a basic command line editing and history mechanism, alongwith tool and button bars that give a point-and-click interface to someR commands. Many of the features of the console are currentlystubs. The <code>gtk()</code> graphics device is a port of the <code>x11()</code>device to <small>GDK</small> (the GIMP Drawing Kit). The <code>gnome()</code>device uses the <small>GNOME</small> canvas.<p>Due to its experimental nature, the <small>GNOME</small> interface for Rwill not be built automatically. You must specify it by runningconfigure with the <code>--with-gnome</code> option. For example, you mightrun<pre>./configure --with-gnome</pre><p>but please check you have all the requirements first. The<small>GNOME</small> interface for R is currently being developed under<small>GNOME</small> 1.4, and is not guaranteed to work with previousversions. You therefore need at least the following libraries installed<pre>audiofile-0.2.1esound-0.2.23glib-1.2.10gtk+-1.2.10imlib-1.9.10ORBit-0.5.12gnome-libs-1.4.1.2libxml-1.8.16libglade-0.17</pre><p>It is preferable to have a complete installation of the <small>GNOME</small>desktop environment. If you use Linux, then this should be providedwith your distribution. In addition, packaged binary distributions ofGNOME are available from <a href="http://www.ximian.com">http://www.ximian.com</a> for the mostpopular Linux distributions and for Solaris.<p>Remember that some package management systems (such as <small>RPM</small> anddeb) make a distinction between the user version of a package and thedeveloper version. The latter usually has the same name but with theextension "-devel". If you use a pre-packaged version of <small>GNOME</small>then you must have the developer versions of the above packages in orderto compile the R-GNOME interface.<p>The full list of <small>GNOME</small> options to configure is<dl><dt><code>--with-gnome</code><dd>use <small>GNOME</small>, or specify its prefix [no]<br><dt><code>--with-gnome-includes=<var>DIR</var></code><dd>specify location of <small>GNOME</small> headers<br><dt><code>--with-gnome-libs=<var>DIR</var></code><dd>specify location of <small>GNOME</small> libs<br><dt><code>--with-libglade-config=<var>LIBGLADE_CONFIG</var></code><dd>specify location of <code>libglade-config</code></dl><a name="Platform%20notes"></a><h2>B.7 Platform notes</h2><p>This section provides some notes on building R on different Unix-likeplatforms. These notes are based on tests run on one or two systemsin each case with particular sets of compilers and support libraries.Success in building R depends on the proper installation and functioningof support software; your results may differ if you have other versionsof compilers and support libraries.</ul><a name="MacOS%20X"></a><h3>B.7.1 MacOS X</h3><p>You can build R as a Unix application on MacOS X. You will need theDevTools, <code>f2c</code> or <code>g77</code>, and the <code>dlcompat</code>library. You will also need to install an X sub-system or configurewith <code>--without-x</code>.<p><code>f2c</code>, <code>g77</code>, the <code>dlcompat</code> library, and X serverand support libraries are available from the Fink project(<a href="http://fink.sourceforge.net">http://fink.sourceforge.net</a>). At the time of writing<code>f2c</code> and <code>g77</code> were not available as part of the Finkbinary distribution and needed to be installed directly; for example for<code>g77</code> use<pre>fink install g77</pre><p>Fink prefers to install in <code>/sw</code> so <code>CPPFLAGS</code>, <code>LDFLAGS</code>need to be set accordingly. If you want to use Tcl/Tk, also availablefrom Fink, then you will also need to use the <code>configure</code>options to specify the Tcl and Tk config locations.<a name="Solaris"></a><h3>B.7.2 Solaris on Sparc</h3><p>R has been built successfully on Solaris 2.7 using<code>gcc</code>/<code>g77</code> and the SunPro WorkShop 6 compilers, andless regularly on 2.5.1, 2.6 and 8. GNU <code>make</code> is needed priorto 2.7 for building other than in the source tree, and perhaps eventhen.<p>When using the SunPro compilers do <em>not</em> specify <code>-fast</code>, asthis disables <small>IEEE</small> arithmetic and <code>make check</code> willfail. The maximal set of optimization options known to work is<pre>-xlibmil -xO5 -dalign</pre><p>We have found little performance difference between <code>gcc</code> and<code>cc</code> but considerable benefit from using a SunPro Fortrancompiler: the <code>gcc</code>/<code>f77</code> combination works well.<p>To compile for a 64-bit target on Solaris (which needs an UltraSparcchip and for support to be enabled in the OS) we used<pre>CC="cc -xarch=v9"CFLAGS="-xO5 -xlibmil -dalign"FC="f95 -xarch=v9"FFLAGS="-xO5 -xlibmil -dalign"CXX=CCCXXFLAGS="-xO5 -xlibmil -dalign -xarch=v9"</pre><p>in <code>config.site</code>. Note that using <code>f95</code> allows the Sunperformance library to be selected: it will not work with <code>f77</code>,nor with <code>g77</code>.<p>Some care is needed to ensure that libraries found by <code>configure</code>are compatible with the R executable and modules, as the testingprocess will not detect many of the possible problems. For 32-bitbuilds under <code>cc</code> the flag <code>-dalign</code> is needed for some ofthe Sun libraries: fortunately the equivalent flag for <code>gcc</code>,<code>-munaligned-doubles</code>, is the default. In theory, libraries suchas <code>libpng</code>, <code>libjpeg</code>, <code>zlib</code> and the ATLAS librariesneed to be built with a <code>pic</code> or <code>PIC</code> flag, which could bea problem if static libraries are used. In practice this seems togive little problem for 32-bit builds, but seems essential for 64-bitbuilds.<p>For a 64-bit build, 64-bit libraries must be used. As theconfiguration process starts with <code>LIBS=/usr/local/lib</code> you mayneed to reset it to avoid finding 32-bit addons.<a name="HPUX"></a><h3>B.7.3 HPUX</h3><p>R has been built successfully on HPUX 10.2 and HPUX 11.0 using bothnative compilers and <code>gcc</code>. By default, R is configured to use<code>gcc</code> and <code>g77</code> on HPUX (if available). Someinstallations of <code>g77</code> only install a static version of the<code>g2c</code> library that cannot be linked into a shared library sinceits files have not been compiled with the appropriate flag for producingposition independent code (<small>PIC</small>). This will result in<code>make</code> failing with a linker error complaining that code needsto be compiled with a <code>+z</code> or <code>+Z</code> flag, the native<code>cc</code> <small>PIC</small> flag. If this is the case you either need tomodify your <code>g77</code> installation or configure with the<pre>--with-f77=fort77</pre><p>flag to specify use of the native <small>POSIX</small>-compliant FORTRAN 77compiler.<p>You may find that <code>configure</code> detects other libraries, such asBLAS, that R needs to use as shared libraries but are only available asstatic libraries. If you cannot install shared versions you will needto tell <code>configure</code> not to use these libraries.<p>Some versions of <code>gcc</code> may contain what appears to be a bug atthe <code>-O2</code> optimization level that causes<pre>> 2 %/% 2[1] 1> 1:2 %/% 2[1] 0 0 # wrong!!</pre><p>which will cause <code>make check</code> to fail. If this is the case, youshould use <code>CFLAGS</code> to specify <code>-O</code> as the optimizationlevel to use.<p>Some systems running HPUX 11.0 may have a <code>gcc</code> that wasinstalled under HPUX 10.2. Between versions 10.2 and 11.0 HPUX changedits support functions for <small>IEEE</small> arithmetic from the recommendedfunctions of the <small>IEEE</small> standard to the ones specified in theC9x draft standard. In particular, this means that <code>finite</code> hasbeen replaced by <code>isfinite</code>. A <code>gcc</code> configured for HPUX10.2 run on 11.0 will not find <code>isfinite</code>, and as a result<code>configure</code> does not recognize the machine as fully supporting<small>IEEE</small> arithmetic and does not define <code>IEEE_754</code> whencompiling C code. This results in a failure in <code>make check</code>.The best solution is to install a properly configured <code>gcc</code>. Analternative work-around is to add <code>-DIEEE_754</code> to the<code>CFLAGS</code> variable.<p>You can configure R to use both the native <code>cc</code> and<code>fort77</code> with (assuming you are using a <code>csh</code> shell)<pre>env CC=cc ./configure --with-f77=fort77</pre><a name="IRIX"></a><h3>B.7.4 IRIX</h3><p>R has been built successfully on IRIX64 6.5 using<code>gcc</code>/<code>f77</code> or <code>cc</code>/<code>f77</code> for 32-bitexecutables and the native compilers for a 64-bit executable. Thecommand<pre>env CC="cc -64" ./configure --with-f77="f77 -64" --with-tcltk=no</pre><p>was used to create the 64-bit executable. It was necessary toexplicitly omit Tcl/Tk because <code>configure</code> would find the 32-bitversion but not detect that is was incompatible with a 64-bit build.<p>A 32-bit build using <code>gcc</code>/<code>g77</code> passed <code>makecheck</code> but failed <code>make test-all-extras</code> in the complex LAPACKtests.<a name="Alpha%2fOSF1"></a><h3>B.7.5 Alpha/OSF1</h3><p>R has been built successfully on an Alpha running OSF1 V4.0 using<code>gcc</code>/<code>g77</code> and <code>cc</code>/<code>f77</code>. Mixing<code>cc</code> and <code>g77</code> fails to configure. The<code>configure</code> option <code>--without-blas</code> was used since thenative blas seems not to have been built with the flags needed tosuppress <code>SIGFPE</code>'s. Currently R does not set a signal handler for<code>SIGFPE</code> on platforms that support <small>IEEE</small> arithmetic, sothese are fatal.<p><code>make check</code> passes with no problems. <code>maketest-all-extras</code> in the <code>tests</code> directory fails at the end of<code>reg-tests-1.R</code> since this system does not have <code>vsnprintf</code>.As currently written, the test at the end of <code>reg-tests-1.R</code> causesa segfault in this case. You can complete the tests by executing<pre>touch reg-tests-1.Rout</pre><a name="Alpha%2fFreeBSD"></a><h3>B.7.6 Alpha/FreeBSD</h3><p>Attempts to build R on an Alpha with FreeBSD 4.3 have been onlypartly successful. Configuring with <code>-mieee</code> added to both<code>CFLAGS</code> and <code>FFLAGS</code> builds successfully, but tests fail with<code>SIGFPE</code>'s. It would appear that <code>-mieee</code> only defers theserather than suppressing them entirely. Advice on how to complete thisport would be greatly appreciated.<a name="New%20platforms"></a><h1>Appendix C New platforms</h1><p>There are a number of sources of problems when installing R on a newhardware/OS platform. These include<p><strong>Floating Point Arithmetic</strong>: R supports the <small>POSIX</small>,SVID and <small>IEEE</small> models for floating point arithmetic. The<small>POSIX</small> and SVID models provide no problems. The <small>IEEE</small>model however can be a pain. The problem is that there is no agreementon how to set the signalling behaviour; Sun/Sparc, SGI/IRIX and ix86Linux require no special action, FreeBSD requires a call to (the macro)<code>fpsetmask(0)</code> and OSF1 requires that computation be done with a<code>-ieee_with_inexact</code> flag etc. On a new platform you must findout the magic recipe and add some code to make it work. This can oftenbe done via the file <code>config.site</code> which resides in the top leveldirectory.<p>Beware of using high levels of optimization, at least initially. Onmany compilers these reduce the degree of compliance to the<small>IEEE</small> model. For example, using <code>-fast</code> on the SolarisSunPro compilers causes R's <code>NaN</code> to be set incorrectly.<p><strong>Shared Libraries</strong>: There seems to be very little agreementacross platforms on what needs to be done to build shared libraries.there are many different combinations of flags for the compilers andloaders. GNU libtool cannot be used (yet), as it currently does notfully support FORTRAN (and will most likely never support <code>f2c</code>:one would need a shell wrapper for this). The technique we use is tofirst interrogate the X window system about what it does (using<code>xmkmf</code>), and then override this in situations where we knowbetter (for tools from the GNU Compiler Collection and/or platforms weknow about). This typically works, but you may have to manuallyoverride the results. Scanning the <code>cc(1)</code> and <code>ld(1)</code>manual entries usually reveals the correct incantation. Once you knowthe recipe you can modify the file <code>config.site</code> (following theinstructions therein) so that the build will use these options.<p>If you do manage to get R running on a new platform please let usknow about it so we can modify the configuration procedures to includethat platform.<p>If you are having trouble getting R to work on your platform pleasefeel free to get in touch to ask questions. We've had a fair amountof practice at porting R to new platforms <small>...</small>.<a name="Function%20and%20variable%20index"></a><h1>Function and variable index</h1><ul compact><li><code>configure</code>: <a href="#Using%20make">Using make</a>, <a href="#Configuration%20variables">Configuration variables</a>, <a href="#Installation">Installation</a>, <a href="#Simple%20compilation">Simple compilation</a><li><code>install.packages</code>: <a href="#Installing%20packages">Installing packages</a><li><code>make</code>: <a href="#Using%20make">Using make</a><li><code>R_HOME</code>: <a href="#Simple%20compilation">Simple compilation</a><li><code>remove.packages</code>: <a href="#Removing%20packages">Removing packages</a><li><code>rsync</code>: <a href="#Using%20rsync">Using rsync</a><li><code>update.packages</code>: <a href="#Updating%20packages">Updating packages</a></ul><a name="Concept%20index"></a><h1>Concept index</h1><ul compact><li>FORTRAN: <a href="#Using%20FORTRAN">Using FORTRAN</a><li>Help pages: <a href="#Simple%20compilation">Simple compilation</a><li>Installation: <a href="#Installation">Installation</a><li>Installing under MacOS: <a href="#Installing%20R%20on%20Classic%20MacOS">Installing R on Classic MacOS</a><li>Installing under Unix: <a href="#Installing%20R%20under%20Unix">Installing R under Unix</a><li>Installing under Windows: <a href="#Installing%20R%20under%20Windows">Installing R under Windows</a><li>Linux: <a href="#Installing%20R%20under%20Unix">Installing R under Unix</a><li>MacOS X: <a href="#Installing%20R%20on%20Classic%20MacOS">Installing R on Classic MacOS</a>, <a href="#Installing%20R%20under%20Unix">Installing R under Unix</a><li>Manuals: <a href="#Making%20the%20manuals">Making the manuals</a><li>Manuals, installing: <a href="#Installation">Installation</a><li>Obtaining R: <a href="#Obtaining%20R">Obtaining R</a><li>Packages: <a href="#Add-on%20packages">Add-on packages</a><li>Packages, installing: <a href="#Installing%20packages">Installing packages</a><li>Packages, removing: <a href="#Removing%20packages">Removing packages</a><li>Packages, updating: <a href="#Updating%20packages">Updating packages</a><li>Patch files: <a href="#Getting%20and%20unpacking%20the%20sources">Getting and unpacking the sources</a><li>Sources for R: <a href="#Getting%20and%20unpacking%20the%20sources">Getting and unpacking the sources</a></ul><hr><h4>Footnotes</h4><ol type="1"><li><a name="fn-1"></a><p>if you have Perl and the source-codepackage files installed</p><li><a name="fn-2"></a><p>Using the SunPro <code>cc</code> and <code>f95</code>compilers</p><li><a name="fn-3"></a><p>On HPUX <code>fort77</code> is the <small>POSIX</small>compliant FORTRAN compiler, and comes second in the search list.</p><li><a name="fn-4"></a><p>as well as its equivalence to the <code>Rcomplex</code>structure defined in <code>R_ext/Complex.h</code>.</p><li><a name="fn-5"></a><p>In particular, avoid <code>g77</code>'s<code>-pedantic</code>, which gives confusing error messages.</p><li><a name="fn-6"></a><p>e.g., to use an optimized BLAS onSun/Sparc</p></ol><hr></body></html>