HowToBuildR ForSolaris

From BRF-Software
Jump to navigation Jump to search

Tips how to build R and Bioconductor using the SunPro 12.1 Compiler Suite

Synopsis

This pages gives some hints on how R and Boioconductor can be compiled using the Sun Compilers. This works at the CeBiTec. If you try that somwhere else your milage may vary. Using gcc everything might be different. Most tips are given as shell commands. Note: a simple


 configure
 make
 make install


will not work. You have to set more options, that's what this page is for.

Preconditions

Checking the versions of the compilers, yours should be same or higher:


azteca~> which cc
/vol/studio-12.1/bin/cc
azteca:~> cc -V
cc: Sun C 5.10 SunOS_i386 Patch 142363-02 2009/09/21
azteca:~> which CC
/vol/studio-12.1/bin/CC
azteca:~> CC -V
CC: Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
azteca:~> which f95
/vol/studio-12.1/bin/f95
azteca:~> f95 -V
CC: Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
azteca:~> uname -a
SunOS azteca 5.10 Generic_142901-03 i86pc i386 i86pc Solaris


This information must as minimum be provided when reporting build problems.

Reporting Problems

  • read "R Installation and Administration" document from "CRAN"
  • report build or compilation errors of R to the R-devel mailing list not to R-help
  • report error in Bioconductor errors to the bioconductor mailing list not to R
  • before reporting an error you must download and try to build the latest R-patched from the R-homepage
  • search first for a related problem using search terms Sun Pro, Sun C, Solaris
  • add the output of the compiler including the error message
  • try to analyse the problem in depth before making any complaint, try to be helpful

Download sources

Building

  • R must be built for each architecture individually: i386 (32bit), amd64 (64bit) and sparc
  • If building a new version start on the faster one, aka. opteron, use qxterm86 to get a build machine or use azteca
  • Use qxterm for a sparc machine
  • change to your source directory cd R-version-x86

Configure

  • To enable configure to find all the libraries, you need to configure environment variables
  • Use a little script, save this in your source directory:
#!/usr/bin/sh

# Set the prefic to your versioned architecture specific volume
# If you just want to test building use a local directory
PREFIX=/vol/r-<version>
# please note: this script was tested on r-2.11

# use this per:
PERL_PREFIX=/vol/perl-5.8.8
TCL_PREFIX=/vol/tcl-8.4.13
CSW_PREFIX=/vol/studio-12.1

CC="cc -xc99"
CPPFLAGS="-I$CSW_PREFIX/include/"
CPPFLAGS="$CPPFLAGS -I$TCL_PREFIX/include -I/vol/local/include -I/vol/graphics/include -I/vol/gnu/include -I/vol/gnu/include/readline"
CFLAGS="-O -xlibmieee"
F77="f95"
FFLAGS=-O4
CXX="CC"
CXXFLAGS="-O"
#R recommendation (liberal interpretation): CXXFLAGS="-O -features=tmplrefstatic"
#Michi recommended: FC="f95  -xO2"
FC="f95"
FCFLAGS=$FFLAGS
LDFLAGS="-lCstd -lCrun -L$CSW_PREFIX/lib -R$CSW_PREFIX/lib"
LDFLAGS="$LDFLAGS -L$TCL_PREFIX/lib -R$TCL_PREFIX/lib -L/vol/local/lib -R/vol/local/lib -L/vol/graphics/lib -R/vol/graphics/lib  -L/vol/gnu/lib -R/vol/gnu/lib -R$PREFIX/lib/R/library/RSPerl/libs -R$PREFIX/lib/R/bin"
SHLIB_CXXLDFLAGS="-lCstd -lCrun -G -L$CSW_PREFIX/lib -R$CSW_PREFIX/lib"

# To build a 64 bit version of R (amd64) use the following options:
# Suggestion: Add an architecture dependent flag to the configure arguments, both versions can afterwards be installed into the same directory.
# See below for further details...
#CC="cc -xc99 -m64"
#CPPFLAGS="-I$CSW_PREFIX/include/"
#CPPFLAGS="$CPPFLAGS -I$TCL_PREFIX/include -I/vol/local/include -I/vol/graphics/include -I/vol/gnu/include -I/vol/gnu/include/readline"
#CFLAGS="-O -xlibmieee"
#F77="f95 -m64"
#FFLAGS=-O4
#CXX="CC -m64"
#CXXFLAGS="-O"
#FC="f95 -m64"
#FCFLAGS=$FFLAGS
#LDFLAGS="-lCstd -lCrun -L$CSW_PREFIX/lib -R$CSW_PREFIX/lib"
#LDFLAGS="$LDFLAGS -L$TCL_PREFIX/lib -R$TCL_PREFIX/lib -L/vol/local/lib -R/vol/local/lib -L/vol/graphics/lib -R/vol/graphics/lib  -L/vol/gnu/lib/amd64 -R/vol/gnu/lib/amd64 -R$PREFIX/lib/R/library/RSPerl/libs -R$PREFIX/lib/R/bin"
#SHLIB_CXXLDFLAGS="-lCstd -lCrun -G -L$CSW_PREFIX/lib -R$CSW_PREFIX/lib"

export CC
export CPPFLAGS
export CFLAGS
export F77
export FFLAGS
export CXX
export CXXFLAGS
export FC
export FCFLAGS
export LDFLAGS
export SHLIB_CXXLDFLAGS

# to help finding gnome-config
#PATH=/vol/gnu/bin:/vol/graphviz-2.8/bin:/vol/graphics/bin:/vol/perl-5.8.8/bin:/vol/java-1.5.0/bin:/vol/mysql-5.0.45/bin:/vol/qt-3.3.8/bin:/vol/subversion-1.3.0/bin:/vol/gtk-1.2.10/bin:/vol/emboss-2.9.0/bin:/vol/biotools/bin:/vol/thunderbird-2.0/bin:/vol/firefox-3.0/bin:/vol/gnu/bin:/vol/local/bin:/vol/cups/bin:/opt/staroffice9/bin:/vol/X11/bin:/usr/dt/bin:/usr/openwin/bin:/vol/tex-2008/bin:/vol/studio-12/bin:/usr/bin:/usr/ccs/bin:/usr/ucb:/usr/local/bin:/vol/codine-6.0/bin/sol-x86

# use the THIS perl
#PATH=$PERL_PREFIX/bin:$TCL_PREFIX/bin:$PATH
#export PATH

# Set default paper size for R
R_PAPERSIZE=A4
export R_PAPERSIZE

# For optimal performance, the Sun Performance library (libsunperf) as part of the Studio compiler suite should be used.
# But - although compilation succeeded on both i386 and amd64 - tests failed on amd64. 
# Maybe this is fixed in a newer version of the Sun compiler? To try out append the following two configure flags:
# --with-blas=-lsunperf
# --with-lapack=-lsunperf

# Use an architecture-dependent subdir to build both i386 and amd64 versions of R into the same directory.
# Common files are shared between both versions, while architecture dependent files will be stored in a
# appropriate sub-directories.
# Uncomment the following two lines to build R on amd64.
# Suggestion: Leave out the flag for one of the builds.
# Note: The last build version will be the default, regardless of the architecture-dependent flag
# Note: Packages are always build for all versions automatically.
# r_arch="amd64"
# export r_arch

./configure --prefix=$PREFIX \
                --with-recommended-packages \
		--with-readline \
		--enable-R-shlib \
		--enable-shared \
		--with-jpeglib \
		--with-libpng\
		--with-tcl-config=$TCL_PREFIX/lib/tclConfig.sh \
		--with-tk-config=$TCL_PREFIX/lib/tkConfig.sh


  • run the configure script:
 > sh buildR.sh
....

R is now configured for i386-pc-solaris2.10

  Source directory:          .
  Installation directory:    /vol/r-2.11

  C compiler:                cc -xc99 -O -xlibmieee
  Fortran 77 compiler:       f95 -O4

  C++ compiler:              CC -O
  Fortran 90/95 compiler:    f95 -O4
  Obj-C compiler:            gcc -g -O2

  Interfaces supported:      X11, tcltk
  External libraries:        readline # Removed due to test errors (see R-documentation): BLAS(SunPerf), LAPACK(SunPerf) 
  Additional capabilities:   PNG, JPEG, TIFF, NLS, cairo
  Options enabled:           shared R library, shared BLAS (see above), R profiling, Java

  Recommended packages:      yes

azteca:~/src/r/R-2.11.1.X86> 


If something is wrong look into the file configure.log.

Make it

This will make the thing using 10 parallel processes, use less for small hosts and have a look at the current load of your chosen host!

azteca> make -j10


Check

make check

that should print *OK* for each test

Install

make install


Again

  • Repeat configure, make, make check, make install for each architecture

Installing additional Packages

  • Note: each package must be installed for each separately installed architecture (this is not needed in case r_arch is used!)
  • You can install add on packages from inside R using install.packages()
  • This is for CRAN packages, Bioconductor packages are installed in a different way
> install.packages("sma")
# choose a mirror
> install.packages(c("sma", "vioplot")) # to install multiple packages
  • If you got problems installing the package, you can download it from CRAN and install it manually
  • The RSPerl package and other locally optimized packages (e.g. amap) must be installed this way:
azteca~> /vol/r-<version>/bin/R CMD INSTALL package.version.tar.gz
  • To debug a compilation problem, untar the package, try to fix it and install from a directory
azteca~> tar -xvzf package.tar.gz
# fix me
azteca~> /vol/r-<version>/bin/R CMD INSTALL package/
  • If there is a problem report the problem to the package maintainer or author first, look into the DESCRIPTION file for the email

Installing RSPerl

see HowToInstallRSPerl

Installing rJava

see HowToInstallRJava

Other Packages

The following packages should not be installed from the repository because they contain patches for our system, which the authors did not apply

  • vioplot (use version 0.3)
  • amap
  • RSPerl (use our version 0.92)

Installing Bioconductor Packages

  • /!\ Some Bioconductor packages currently require TheMeanPthreadHack on our system
  • Bioconductor packages are found on: http://www.bioconductor.org/
  • Follow the installation instructions from the Bioconductor site
  • Report problems to the Bioconductor mailing list
  • To install biobase run in R:
source("http://bioconductor.org/biocLite.R")
biocLite()
  • To install more packages:
biocLite(c('biobla1','bioblubb'))
  • You can also download bioconductor packages from

Installing all packages from the previous version

  • Often you want to have all the packages from the old version in the new one
  • This is a tip to simplify this a bit:
  • You can do this in R:
  • Open the old R binary
azteca~>/vol/old-r/bin/R
allp <- installed.packages()
save(allp, file='~/rpackages.rda')
q()
  • in the new R excute the following script:
azteca~>/vol/new-r/bin/R

load ('~/rpackages.rda')
# do not reinstall already installed packages
allp = setdiff(allp[,1], installed.packages()[,1]) 
cranpackages = intersect(allp, available.packages()[,1])
install.packages(cranpackages)
# install bioconductor basepackage
source("http://bioconductor.org/biocLite.R")
biocLite()
rest = setdiff(allp, installed.packages()[,1])
biocLite(rest)
# this could give an error for some packages not contained in both 
# repositories e.g RSPerl, so install that first