Skip to content

Building R

linuxonz edited this page Dec 31, 2024 · 58 revisions

Building R

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

  • RHEL (8.8, 8.10, 9.2, 9.4, 9.5) have 4.4.2
  • SLES 15 SP6 has 4.3.1
  • Ubuntu 20.04 has 3.6.3
  • Ubuntu 22.04 has 4.1.2
  • Ubuntu 24.04 has 4.3.3
  • Ubuntu 24.10 has 4.4.1

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

  • SLES (15 SP6)
  • Ubuntu (20.04, 22.04, 24.04, 24.10)

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.

1. Build using script

If you want to build R using manual steps, 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.4.2/build_r.sh

# Build R
bash build_r.sh  [Provide -t option for executing build along with tests] 

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

2. Install Dependencies

export SOURCE_ROOT=/<source_root>/

2.1. Install Basic Dependencies

  • SLES (15 SP6)

    sudo zypper install -y curl libnghttp2-devel wget tar rpm-build help2man zlib-devel xz-devel libyui-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 tk xorg-x11-devel perl-macros texinfo texlive-ae texlive-fancyvrb java-11-openjdk 
  • Ubuntu (20.04, 22.04, 24.04, 24.10)

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

2.2. Set Environment Variables

export PATH=/usr/local/bin:$PATH

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

3. Build and Install

cd $SOURCE_ROOT
curl -sSL https://cran.r-project.org/src/base/R-4/R-4.4.2.tar.gz | tar xzf -
mkdir build && cd build
../R-4.4.2/configure --with-x=no --with-pcre1 --disable-java
make -j$(nproc)
sudo make install

Note: Packages such as rJava and JavaGD requires Java8+ to be installed on the host system. To enable these use --enable-java with above configure command.

4. Test (optional)

4.1. Execute test cases

  • For SLES (15 SP6)

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

    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
    

4.2. Check for version of R-package installed

echo "sessionInfo()" | R --save

References:

Clone this wiki locally