I am using gfortran (in the form of mpif90) to link a large mpi program. It all seems to be fine except for one library libgptl.a.
The link step generates a number of errors but all of the form:
libgptl.a(perf_mod.o): in function `__perf_mod_MOD_t_stopf':perf_mod.F90:(.text+0x844): undefined reference to `gptlstop_'
or
perf_mod.F90:(.text+0xa76): undefined reference to `gptlstop_'
If I try "nm libgptl.a" to see what is in the static library, the relevant lines appear to be:
gptl.o: [From gptl.c]
...
0000000000003b76 T GPTLstop
0000000000004040 T GPTLstopf
00000000000042ca T GPTLstopf_handle
0000000000003db9 T GPTLstop_handle
0000000000003a2a T GPTLstop_instr
...
f_wrappers.o [From f_wrappers.c]
...
0000000000000218 T gptlstop
U GPTLstopf
U GPTLstopf_handle
0000000000000226 T gptlstop_handle
...
perf_mod.o [From perf_mod.F90]
...
U gptlstop_
...
00000000000006c7 T __perf_mod_MOD_t_stopf
I guess that the problem is something to do with gfortran placing the underscore at the end of the name.
Is there a simple way to help the linker make the correct connection between names with and without underscores (i.e. gptlstop_ in perf_mod.o and gptlstop in f_wrappers.o) or make the earlier compile step use a more consistent naming?
bind(C,name="...")
. See fortran-iso-c-binding.SYSTEM
andCHDIR
are typically available as intrinsics, you should not need to link them this way if they are called from Fortran. gcc.gnu.org/onlinedocs/gfortran/CHDIR.html gcc.gnu.org/onlinedocs/gfortran/SYSTEM.html If they are declaredEXTERNAL
then you are on your own, but I would just check if the calls conform to the intrinsics and remove theEXTERNAL
.