Hi, I have some code written in C and Fortran that I want to compile into a statically-linked executable. If I compile the code dynamically (using the -fno-underscoring
option for gfortran), it all works fine. However, I want to link it into a .so file, statically linking most of the needed libraries, and then link dynamically to libkrb5
, very much like the method described in this blog post.
I followed the steps in the previous blog post, and I managed to compile the .so library without any problems. nm
shows that it is in good shape, with my Fortran subroutines and C functions showing up:
[...]001020b9 T turnover
[...]000d31ea T initio
The first function is written in Fortran, and the second in C. They don't have underscores or anything, so they should link. My main program (in Fortran) is compiled like the other Fortran source files. When I try to link, though, I get an 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
In main_program.o
, I can see that there's
00000000 T MAIN__
Everything looks in order, so why is it not linking?