I have Ubuntu 14.04 on a 64-bit machine. I would like to run gfortran -m32
for my f77 fortran code that also uses i386 CERN libraries. I downloaded Ubuntu packages cernlib, lib32gfortran-4.8-dev, and gcc-multilib. But I got errors like this when I ran my command:
$ gfortran -m32 -O -o out10 MBpart1ep0.f -L. -lmathlib -lkernlib -Lcuba
/tmp/ccs5Njbz.o: In function `MAIN__':
MBpart1ep0.f:(.text+0x82): undefined reference to `cuhre_'
//usr/local/lib/libmathlib.a(cgamma64.o): In function `wgamma_':
cgamma64.F:(.text+0xd1): undefined reference to `s_wsfi'
cgamma64.F:(.text+0xe5): undefined reference to `do_fio'
cgamma64.F:(.text+0xea): undefined reference to `e_wsfi'
...
To see my full error, go to my previous post.
As someone suggested, these errors are caused by an incompatible f2c library. So I found that there is an i386 f2c library for Ubuntu 14.04. As shown below, I installed the f2c:i386 on my machine, replacing some previous packages. But then I got new errors when running gfortran -m32 ... -lf2c
.
gg@gg-VirtualBox:~$ aptitude search f2c
i A f2c - FORTRAN 77 to C/C++ translator
p f2c:i386 - FORTRAN 77 to C/C++ translator
...
gg@gg-VirtualBox:~$ sudo aptitude install f2c:i386
[sudo] password for gg:
The following NEW packages will be installed:
binutils:i386{ab} cpp:i386{ab} cpp-4.8:i386{ab} f2c:i386{b} gcc:i386{ab}
gcc-4.8:i386{ab} gcc-4.8-base:i386{a} gcc-4.9-base:i386{a}
libasan0:i386{a} libatomic1:i386{a} libc6:i386{a} libc6-dev:i386{a}
libcloog-isl4:i386{a} libf2c2:i386{ab} libf2c2-dev:i386{ab}
libgcc-4.8-dev:i386{a} libgcc1:i386{a} libgmp10:i386{a} libgomp1:i386{a}
libisl10:i386{a} libitm1:i386{a} libmpc3:i386{a} libmpfr4:i386{a}
libquadmath0:i386{a} linux-libc-dev:i386{a} zlib1g:i386{a}
The following packages will be upgraded:
linux-libc-dev
1 packages upgraded, 26 newly installed, 0 to remove and 114 not upgraded.
Need to get 22.5 MB of archives. After unpacking 74.5 MB will be used.
The following packages have unmet dependencies:
libf2c2 : Conflicts: libf2c2:i386 but 20090411-2 is to be installed.
libf2c2:i386 : Conflicts: libf2c2 but 20090411-2 is installed.
cpp-4.8 : Conflicts: cpp-4.8:i386 but 4.8.2-19ubuntu1 is to be installed.
cpp-4.8:i386 : Conflicts: cpp-4.8 but 4.8.2-19ubuntu1 is installed.
binutils : Conflicts: binutils:i386 but 2.24-5ubuntu3 is to be installed.
binutils:i386 : Conflicts: binutils but 2.24-5ubuntu3 is installed.
gcc : Conflicts: gcc:i386 but 4:4.8.2-1ubuntu6 is to be installed.
gcc:i386 : Conflicts: gcc but 4:4.8.2-1ubuntu6 is installed.
cpp : Conflicts: cpp:i386 but 4:4.8.2-1ubuntu6 is to be installed.
cpp:i386 : Conflicts: cpp but 4:4.8.2-1ubuntu6 is installed.
gcc-4.8 : Conflicts: gcc-4.8:i386 but 4.8.2-19ubuntu1 is to be installed.
gcc-4.8:i386 : Conflicts: gcc-4.8 but 4.8.2-19ubuntu1 is installed.
f2c : Conflicts: f2c:i386 but 20100827-1 is to be installed.
f2c:i386 : Conflicts: f2c but 20100827-1 is installed.
libf2c2-dev : Conflicts: libf2c2-dev:i386 but 20090411-2 is to be installed.
libf2c2-dev:i386 : Conflicts: libf2c2-dev but 20090411-2 is installed.
The following actions will resolve these dependencies:
Remove the following packages:
1) f2c
2) fort77
3) libf2c2
4) libf2c2-dev
Keep the following packages at their current version:
5) binutils:i386 [Not Installed]
6) cpp:i386 [Not Installed]
7) cpp-4.8:i386 [Not Installed]
8) gcc:i386 [Not Installed]
9) gcc-4.8:i386 [Not Installed]
Leave the following dependencies unresolved:
10) f2c:i386 recommends gcc:i386
11) libc6-dev:i386 recommends gcc:i386 | c-compiler:i386
Accept this solution? [Y/n/q/?] y
The following NEW packages will be installed:
f2c:i386 gcc-4.9-base:i386{a} libc6:i386{a} libc6-dev:i386{a}
libf2c2:i386{a} libf2c2-dev:i386{a} libgcc1:i386{a}
linux-libc-dev:i386{a}
The following packages will be REMOVED:
f2c{a} fort77{a} libf2c2{a} libf2c2-dev{a}
The following packages will be upgraded:
linux-libc-dev
The following packages are RECOMMENDED but will NOT be installed:
bcc:i386 clang-3.3:i386 clang-3.4:i386 clang-3.5:i386 gcc:i386
gcc-4.4:i386 gcc-4.6:i386 gcc-4.7:i386 gcc-4.8:i386 tcc:i386
1 packages upgraded, 8 newly installed, 4 to remove and 114 not upgraded.
Need to get 7,991 kB of archives. After unpacking 21.9 MB will be used.
Do you want to continue? [Y/n/?] y ...
...
New errors when now using the -lf2c
option (ading -lm
doesn't have an effect). Without this option, the errors are same as before.
gg@gg-VirtualBox:~/Desktop/myfolder$ gfortran -m32 -O -o out10 MBpart1ep0.f -L. -lmathlib -lkernlib -Lcuba -lf2c
/tmp/cc66Jegn.o: In function `MAIN__':
MBpart1ep0.f:(.text+0x82): undefined reference to `cuhre_'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../libf2c.so: undefined reference to `MAIN__'
collect2: error: ld returned 1 exit status
Does anyone know what I can do to fix this problem?