Compiling – Cannot Find -lgfortran

compilingfortrangccld

I'm trying to install a package in R (package "ks"). It fails with error message:

/usr/bin/ld: cannot find -lgfortran

I've already installed the Ubuntu package build-essential:

sudo apt-get install build-essential

I've also tried adding symbolic links:

sudo ln -s /usr/lib/x86_64-linux-gnu/libgfortran.so.3 /usr/lib/libgfortran.so
sudo ln -s /usr/lib/libgfortran.so.3.0.0 /usr/lib/libgfortran.so
sudo ldconfig

I use gcc and g++ regularly, but haven't yet had reason to use gfortran.

I've seen others with this problem on gcc-4.7 (http://ubuntuforums.org/showthread.php?t=2123821), so I wonder if this is from manually installing gcc-4.7. I followed the recipe from the accepted answer here here and here here.

Running lsb_release -a prints

Ubuntu 12.04.2 LTS

and running uname -r prints

3.2.0-39-generic-pae

Can anyone offer advice for why ld doesn't work?

Best Answer

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.

Related Question