I have a function (in case anyone is interested, it is this function) in a module that looks like this
MODULE MYMODULE
IMPLICIT NONE
! Some random stuff
CONTAINS
CHARACTER*255 FUNCTION strtok ( source_string, delimiters )
[...]
END FUNCTION strtok
SUBROUTINE DO_SOMETHING ( )
CHARACTER(LEN=255) :: strtok
[...] !
END SUBROUTINE DO_SOMETHING
END MODULE MYMODULE
The strtok
function is a version of C's strings tokenizer, and I'll be using this function from the DO_SOMETHING
subroutine. I need to define strtok
, otherwise gfortran complains about it being not defined. However, if I do, and compile my code and link it to the main program, the linker complains about an undefined reference to strtok_
. I have no idea why this is the case, as they are both in the same module and should be visible. Other functions and subroutines in the same module don't have this problem. Is this something to do with the fact that this is a character*-returning function?