Skip to content

Building R

aborkar-ibm edited this page Aug 12, 2021 · 62 revisions

Building R

Below versions of R are available in respective distributions at the time of creation of these build instructions:

  • Ubuntu 18.04 has 3.4.4
  • Ubuntu 20.04 has 3.6.3
  • Ubuntu 21.04 has 4.0.4
  • SLES 12 SP5, has 3.2.5
  • SLES 15 SP2,15 SP3 has 3.5.0
  • RHEL (8.2, 8.3, 8.4) have 4.1.0

The instructions provided below specify the steps to build R version 4.1.0 on Linux on IBM Z for following distributions:

  • RHEL (7.8, 7.9)
  • SLES (12 SP5, 15 SP2, 15 SP3)
  • Ubuntu (18.04, 20.04, 21.04)

General Notes:

  • When following the steps low please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1. Build using script

If you want to build R manually, go to step 2.

Use the following commands to build R using the build script. Please make sure you have wget installed.

wget https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/R/4.1.0/build_r.sh

# Build R
bash build_r.sh  [Provide -j (AdoptJDK-HotSpot|AdoptJDK-OpenJ9|OpenJDK) -t option for executing build along with tests with specific java ] 

If the build completes successfully, go to step 3.2. In case of error, check logs for more details or go to step 2 to follow manual build steps.

Step 2. Build and Install

2.1) Install dependencies

  • RHEL (7.8, 7.9)

    • With OpenJDK:

        sudo yum install -y gcc wget tar make rpm-build zlib-devel xz-devel ncurses-devel cairo-devel gcc-c++ libcurl-devel libjpeg-devel libpng-devel libtiff-devel readline-devel texlive-helvetic texlive-metafont texlive-psnfss texlive-times xdg-utils pango-devel tcl-devel tk-devel perl-macros info gcc-gfortran libXt-devel  perl-Text-Unidecode.noarch bzip2-devel pcre-devel help2man procps which  java-11-openjdk java-11-openjdk-devel
      
    • With AdoptOpenJDK 11:

      sudo yum install -y gcc wget tar make rpm-build zlib-devel xz-devel ncurses-devel cairo-devel gcc-c++ libcurl-devel libjpeg-devel libpng-devel libtiff-devel readline-devel texlive-helvetic texlive-metafont texlive-psnfss texlive-times xdg-utils pango-devel tcl-devel tk-devel perl-macros info gcc-gfortran libXt-devel  perl-Text-Unidecode.noarch bzip2-devel pcre-devel help2man procps which 
      
      • Download and install AdoptOpenJDK 11 (With Hotspot and OpenJ9 - Normal Heap) from here.
  • SLES (12 SP5, 15 SP2, 15 SP3)

    • With OpenJDK:

      sudo zypper install -y wget tar rpm-build help2man zlib-devel xz-devel ncurses-devel make cairo-devel gcc-c++ gcc-fortran libcurl-devel libjpeg-devel libpng-devel libtiff-devel readline-devel fdupes texlive-helvetic texlive-metafont texlive-psnfss texlive-times xdg-utils pango-devel tcl-devel tk-devel xorg-x11-devel perl-macros texinfo java-11-openjdk java-11-openjdk-devel texlive-ae texlive-fancyvrb
      
    • With AdoptOpenJDK 11:

      sudo zypper install -y wget tar rpm-build help2man zlib-devel xz-devel ncurses-devel make cairo-devel gcc-c++ gcc-fortran libcurl-devel libjpeg-devel libpng-devel libtiff-devel readline-devel fdupes texlive-helvetic texlive-metafont texlive-psnfss texlive-times xdg-utils pango-devel tcl-devel tk-devel xorg-x11-devel perl-macros texinfo texlive-ae texlive-fancyvrb
      
      • Download and install AdoptOpenJDK 11 (With Hotspot and OpenJ9 - Normal Heap) from here.
  • Ubuntu (18.04, 20.04, 21.04)

    • With OpenJDK:

      sudo apt-get install -y wget tar gcc g++ ratfor gfortran libx11-dev make r-base libcurl4-openssl-dev locales openjdk-11-jdk openjdk-11-jdk-headless
      
    • With AdoptOpenJDK 11:

      sudo apt-get update
      sudo apt-get install -y wget tar gcc g++ ratfor gfortran libx11-dev make r-base libcurl4-openssl-dev locales
      
      • Download and install AdoptOpenJDK 11 (With Hotspot and OpenJ9 - Normal Heap) from here.

    Note: At the time of creating these instructions, R has been verified with AdoptOpenJDK 11 with Hotspot (build 11.0.1.0+9) and AdoptOpenJDK 11 with OpenJ9 (build 11.0.1.0+9).

2.2) Set Environment Variables

export JAVA_HOME=<path to java>
export PATH=$JAVA_HOME/bin:$PATH

Note: Make sure /usr/local/bin and /sbin are available in PATH environment variable.

2.3) Download R source code

export SOURCE_ROOT=/<source_root>
cd $SOURCE_ROOT
wget https://cran.r-project.org/src/base/R-4/R-4.1.0.tar.gz
tar zxvf R-4.1.0.tar.gz

2.4) Build and Install R

cd $SOURCE_ROOT
mkdir build && cd build
../R-4.1.0/configure --with-x=no --with-pcre1
make
sudo make install

Step 3: Testing(Optional)

3.1) Execute test cases

  • For RHEL (7.8, 7.9)

    cd $SOURCE_ROOT/build
    yum install -y texlive.s390x
    export LANG="en_US.UTF-8"
    make check
    
  • For SLES (12 SP5, 15 SP2, 15 SP3)

    cd $SOURCE_ROOT/build
    sudo zypper install -y texlive-courier texlive-dvips
    export LANG="en_US.UTF-8"
    make check
    
  • For Ubuntu (18.04, 20.04, 21.04)

    cd $SOURCE_ROOT/build
    sudo apt-get install -y texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra
    sudo locale-gen "en_US.UTF-8"
    sudo locale-gen "en_GB.UTF-8"
    export LANG="en_US.UTF-8"
    make check
    

3.2) Check for version of R-package installed

echo "sessionInfo()" | R --save

References

Clone this wiki locally