I am trying to compile some really old code (1986 and earlier). This code refers to an external function. Today, compilers are asking for much more code to make this work. And I continue to fail. Now I have created a small welcome program that demonstrates the problem.
hello.for
PROGRAM hello
USE func
PRINT *, "Hello World!"
PRINT *, f ()
END PROGRAM hello
func.for
MODULE func
PUBLIC f
CONTAINS
FUNCTION f ()
f='Hello Func'
END FUNCTION
END MODULE
This has not only one, but also two problems:
- How to determine the type of return? Docs reports
<type> FUNCTION <function>or FUNCTION <function> () <type>::<something>, but does not work. - How to make the linker find a function?
gfortran -c func.for works (if I use the default return type real) and creates a mod file, but the link doesn't work
$ gfortran hello.for
/tmp/ccHNzcXA.o: In function `MAIN__':
hello.for:(.text+0xa4): undefined reference to `__func_MOD_f'
collect2: error: ld returned 1 exit status
__func_MOD_fnot contained in the mod file, but in the o file is func.for__func_MOD_f.
Any idea?
thank