How to avoid undefined reference when linking objects in cyclic dependencies in Gfortran

57 Views Asked by At

If one file has two subroutines TEST1 (calling TEST3) and TEST2, and another file with subroutines TEST3 (calling TEST2) and TEST4 (calling TEST1), then the linker will complain about undefined references, no matter what the order will be, in Gfortran, when linking.

In Silverfrost fortran (ftn95) the order is not important. Is there a workaround in Gfortran, as it will fail to link an otherwise valid set of objects? If I put

EXTERNAL TEST3

in TEST1, and similar with the others, will that fix the issue? Moving subroutines to the same file would make the whole source code very cumbersome.

0

There are 0 best solutions below