Linker error: cannot find -lg2c
12 Apr 2012I ran into a problem today trying to compile an old Fortran program. Everything was working until the final link:
gcc -o ./DAlphaBall.f77 -O DAlphaBall.o sos_minor_gmp.o alf_tools_gmp.o adjust.o alfcx.o alfcx_tools.o delcx.o truncate_real.o measure_dvol.o dsurfvol_tools.o vector.o write_simplices.o -lgmp -lg2c -lm
/usr/bin/ld: cannot find -lg2c
collect2: ld returned 1 exit status
The strange thing is that libg2c.so.0 was installed:
$ ls -l /usr/lib64/libg2c*
lrwxrwxrwx 1 root root 15 2010-12-30 12:43 /usr/lib64/libg2c.so.0 -> libg2c.so.0.0.0
-rwxr-xr-x 1 root root 127368 2010-07-05 04:57 /usr/lib64/libg2c.so.0.0.0
After some searching, it seems that libg2c is part of an older version of gfortran, back in the day when it was actually called g77. My problem was that I was using gfortran to compile it (which, therefore, was part of the gcc-4 series) and not g77. On this system, the old version was installed as gcc33-*, and changing the Fortran compiler and CC/LD variables to the appropriate version worked a treat.
Oh, and here's some good technical background on linkers and names.
Add a comment:
Name and email required; email is not displayed.
Related Posts
QRP weekend 08 Oct 2018
Open Source Cubesat Workshop 2018 03 Oct 2018
mpd crash? try removing files in /var/lib/mpd/ 11 Aug 2018