Mixed language statically linked with gfortran and gcc
I have code written in C and Fortran that I want to compile into a statically linked executable. If I compile the code dynamically (using the parameter -fno-underscoring
for gfortran) everything works fine. However, I want to link it to a .so file, statically link most of the required libraries, and then dynamically link to libkrb5
, very similar to the method described in this blog post .
I followed the steps in the previous blog post and I was able to compile the .so library without any problem. nm
shows that it's in good shape, with my Fortran routines and C functions:
[...]001020b9 T turnover
[...]000d31ea T initio
The first function is written in Fortran, the second in C. They don't have underscores or anything else, so they must be linked. My main program (in Fortran) is compiled like the other Fortran source files. However, when I try to install the link, I get the error:
gfortran -m32 main_program.o -o program_static -L./ -llibname -lkrb5 -lgssapi_krb5 -lsasl2 -lgfortran
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/crt1.o: In function `_start':
/build/buildd/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status
B main_program.o
, I can see what's there
00000000 T MAIN__
Everything looks fine, so why isn't it related?
source to share