0

I am working on a project that uses the package plotly in R. When I tried installing plotly, hexbin (a dependency) would not compile, because it could not find the gfortran .so libraries. I have already installed gfortran (gcc64-gfortran.x86_64), but the .so files are not installed or discoverable by ld. Here is the relevant part of the log:

$ R
> install.packages("hexbin", repos = "http://cran.rstudio.com/")
Installing package into ‘/home/ec2-user/R/x86_64-redhat-linux-gnu-library/3.4’

...

gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -L/usr/local/lib64 -o hexbin.so hbin.o hcell.o herode.o hsm.o reg.o -lgfortran -lm -lquadmath - L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
/usr/bin/ld: cannot find -lquadmath
collect2: error: ld returned 1 exit status

Running ld -lgfortran --verbose gives me this:

...

==================================================
attempt to open /usr/x86_64-amazon-linux/lib64/libgfortran.so failed
attempt to open /usr/x86_64-amazon-linux/lib64/libgfortran.a failed
attempt to open /usr/lib64/libgfortran.so failed
attempt to open /usr/lib64/libgfortran.a failed
attempt to open /usr/local/lib64/libgfortran.so failed
attempt to open /usr/local/lib64/libgfortran.a failed
attempt to open /lib64/libgfortran.so failed
attempt to open /lib64/libgfortran.a failed
attempt to open /usr/x86_64-amazon-linux/lib/libgfortran.so failed
attempt to open /usr/x86_64-amazon-linux/lib/libgfortran.a failed
attempt to open /usr/local/lib/libgfortran.so failed
attempt to open /usr/local/lib/libgfortran.a failed
attempt to open /lib/libgfortran.so failed
attempt to open /lib/libgfortran.a failed
attempt to open /usr/lib/libgfortran.so failed 
attempt to open /usr/lib/libgfortran.a failed
ld: cannot find -lgfortran

yum info gcc64-gfortran.x86_64 says that my installation of gfortran is at version 6.4.1 from amzn-main.

1

I had the same issue with a standard AWS Linux instance.
I had to link both, gfortran and quadmath:

sudo ln -s /usr/lib/gcc/x86_64-amazon-linux/6.4.1/libquadmath.so /usr/lib/libquadmath.so
New contributor
Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Sorry! I forgot to mention libquadmath as well! +1 – Mason Jones Jan 16 at 23:36
0

I found the problem. When I searched for the .so fortran file, I used the find command incorrectly. I was using find / -file gfortran.so instead of find / -file *gfortran*. I simply linked it with sudo ln -s /usr/lib/gcc/x86_64-amazon-linux/6.4.1/libgfortran.so /usr/lib/libgfortran.so, and now the link is resolved.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.