How to install R version 3.2.1 – collect2: error: ld returned 1 exit status

5,921

For a full list of steps to install a version from source, skip the following lines and read on with Install from source


To install/remove the GNU R statistical computation and graphics system you need the package r-base.

Therefore

sudo apt-get install r-base

or

sudo apt-get purge r-base

To install/remove the GNU R collection of recommended packages you need r-recommended

sudo apt-get install r-recommended 

or

sudo apt-get install r-recommended

Install from source

The version 3.2.1 is in the Wily Universe repositories.

To install the version 3.2.1 on older Ubuntu versions, you have to compile the packages for yourself

  1. Download and extract

    cd
    wget https://cran.r-project.org/src/base/R-3/R-3.2.1.tar.gz
    sudo apt-get install tcl tcl-dev tk-dev tk 
    tar xf R-3.2.1.tar.gz
    cd R-3.2.1
    
  2. Create a Makefile with configure and enable shared libraries (--enable-R-shlib) and Tcl/TK-support (--with-tcltk)

    ./configure --prefix=/usr/local --enable-R-shlib --with-tcltk
    

    or simply with (without shared libraries)

    ./configure
    
  3. And start the build process

    make
    
  4. After that, install. I prefer the installation with checkinstall, to create and install a deb package

    sudo apt-get install checkinstall
    sudo checkinstall
    

    But you could also use the standard way

    sudo make install
    

And now, you have version 3.2.1 installed

 % /usr/local/bin/R

R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 

Install RStudio Desktop

Download the latest version here, e.g.

wget https://download1.rstudio.org/rstudio-0.99.467-amd64.deb

Install via

sudo dpkg -i rstudio-0.99.467-amd64.deb

Check the install output and install missing packages, e.g. in my case

sudo apt install libjpeg62

Start RStudio via Unity Dash or GNOME Activities or via command line

/usr/lib/rstudio/bin/rstudio

enter image description here

Share:
5,921
niyas
Author by

niyas

I'm a Data Science Engineer with extensive experience in building Data Applications. I have built solutions for Fortune 500 companies, helping them save millions by automating insights generation from data. The current core focus of interest is Machine Learning Engineering and Data Engineering.

Updated on September 18, 2022

Comments

  • niyas
    niyas almost 2 years

    I'm trying to install R version 3.2.1. I executed the following code

    ./configure --enable-R-shlib
    

    followed by make command. But the following error is obtained.

    /usr/bin/ld: ../appl/dchdc.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
    ../appl/dchdc.o: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    

    Please help me to resolve this or let me know how to remove this specific version of R. Because when I run sudo apt-get --purge autoremove R,

    E: Unable to locate package R
    
  • niyas
    niyas almost 9 years
    There is no typo error. I tried the above code. But I got the previous error followed by these error make[3]: *** [libR.so] Error 1 make[3]: Leaving directory /home/niyas/Downloads/R-3.2.1/src/main'` make[2]: *** [R] Error 2 make[2]: Leaving directory /home/niyas/Downloads/R-3.2.1/src/main'` make[1]: *** [R] Error 1 make[1]: Leaving directory /home/niyas/Downloads/R-3.2.1/src'` make: *** [R] Error 1
  • niyas
    niyas almost 9 years
    I can install R 3.2.1 using the following code.. ./configure make sudo make install . But when I pass --enable-R-shlib to the configuration script it will throw the above error. And I can't open Rstudio without enabling R-Shlib. It throws an error If this is a custom build of R, was it built with the --enable-R-shlib option?
  • A.B.
    A.B. almost 9 years
    It's a typo ./configure--enable-R-shlib gives bash: ./configure--enable-R-shlib: No such file or directory
  • A.B.
    A.B. almost 9 years
    remove your source folder and follow my instructions step by step
  • A.B.
    A.B. almost 9 years
    Have you started ./configure with --enable-R-shlib?
  • niyas
    niyas almost 9 years
    Yes. I did exact 5 steps in your answer. And I tried to manually copy the libR.so file, but it the permission got denied. Btw, I'm the admin.
  • A.B.
    A.B. almost 9 years
    Give me a second, I'm building the packages again.
  • A.B.
    A.B. almost 9 years
    RStudio Desktop 0.99.467?
  • niyas
    niyas almost 9 years
    Yes. rstudio-0.99.467-amd64
  • A.B.
    A.B. almost 9 years
    Ok, go into the source folder and start a make uninstall; make clean and start the whole procedure again.
  • Fabby
    Fabby almost 9 years
    @Niyas: what's the result of the last command?
  • niyas
    niyas almost 9 years
    @Fabby The source folder is in my home directory. But I can't navigate to the source folder through terminal. Is there any command? It says, there is no directory R 3.2.1, but it is there. My file path is home/R-3.2.1
  • A.B.
    A.B. almost 9 years
    /home/R-3.2.1/ ? Really?
  • A.B.
    A.B. almost 9 years
    I hope, /home/R-3.2.1/ is really the source folder and not your home folder. Delete the folder with sudo rm -r /home/R-3.2.1
  • niyas
    niyas almost 9 years
    I said /home/R-3.2.1/ is my source folder. I executed the above command. And it says rm: cannot remove ‘/home/R-3.2.1’: No such file or directory.
  • A.B.
    A.B. almost 9 years
    Ok, what is the output of sudo ls -la --escape /home
  • niyas
    niyas almost 9 years
    total 12 drwxr-xr-x 3 root root 4096 May 16 2014 . drwxr-xr-x 23 root root 4096 Feb 8 11:43 .. drwxr-xr-x 38 niyas niyas 4096 Aug 2 20:46 niyas
  • A.B.
    A.B. almost 9 years
    As you can see, there is no /home/R-3.2.1. Remove the folder inside your home folder. I assume /home/niyas/R-3.2.1. Therefore rm -r /home/niyas/R-3.2.1
  • niyas
    niyas almost 9 years
    Thanks. I have removed the directory and uninstalled R. But I can access R 3.2.1 by command line even though it is not in software center. How is that possible?
  • A.B.
    A.B. almost 9 years
    How did you uninstall the program? The Software Center and an installation with make install are completely different things. Therefore the hint to install with checkinstall as you can read in my answer.
  • niyas
    niyas almost 9 years
  • A.B.
    A.B. almost 9 years
    @Pilot6 Test test
  • niyas
    niyas almost 9 years
    @A.B. It worked. Thanks a lot. I have been working on this for almost a week.
  • guntbert
    guntbert over 8 years
    You really should explain what this does and why it will help.