Andrew Redd Andrew Redd - 1 year ago 78
R Question

Building R package getting error "ld: cannot find -lgfortran "

I'm trying to install the package lars. Ubuntu 11.04 Natty 64-bit. From building I get:

* installing *source* package âlarsâ ...
** libs
gfortran -fpic -O3 -pipe -g -c delcol.f -o delcol.o
gcc -shared -o delcol.o -lgfortran -lm -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
collect2: ld returned 1 exit status
make: *** [] Error 1
ERROR: compilation failed for package âlarsâ

gfortran is installed and when I run
gfortran --version
I get

gfortran --version GNU Fortran
(Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2

sudo ldconfig -v
gives the error

/sbin/ldconfig.real: Cannot stat /usr/lib/ No such file or directory

I have already removed and reinstalled gfortran. What do I need to fix this?

Answer Source

For the Debian / Ubuntu family, we usually recommend

 $ sudo apt-get install r-base-dev

as it pulls in all packages commonly needed for compiling. And this approach gets tested all the time as the automated package builders rely on this (as well as additional per-package Build-Depends). The gfortran package is listed here too; maybe you have a broken link from a prior installation so I'd also try dpkg --purge gfortran; apt-get install gfortran. That said, dozens of R packages (and R itself) use Fortran so there should not be any magic here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download