Cannot find -lgfortran

A little more explanation to Cloud Oliver's answer.

Find out the gcc version currently being used through this command.

$sudo update-alternatives --config gcc

* 2            /usr/bin/gcc-4.7   60        manual mode

The entry with * tells which version of GCC is being used. Just press enter to keep the current settings.

If it prints "no alternatives for gcc", you might have to use this command to find out the version:

apt-cache policy gcc
  1. cd to the right gcc directory (replace the version number with yours):

    cd /usr/lib/gcc/x86_64-linux-gnu/4.7/
    
  2. You can search for libgfortran.a with the following command (optional). In my case it was present in the /usr/lib/gcc/x86_64-linux-gnu/4.8/ directory.

    find /usr/lib/gcc/x86_64-linux-gnu/ -name libgfortran.a
    
  3. Create the symlink:

    sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.a libgfortran.a
    

What I did, I check on ubuntu if the versions of g++, gcc and g are the same or not.

I guess it is better if you have all the three of same version.

# first check the versions:
gcc --version
g++ --version
gfortran --version

# If versions are different, then install:
sudo apt-get update
apt-get install gcc-4.9 g++-4.9 gfortran-4.9

For me this resolved all the issues which I was facing while installing "TTR" package in R using RStudio on Ubuntu.


You need to install gfortran. The error points out that the static lib for build-time linking is missing not the dynamic libs you tried to adjust.