I'm writing an example script in Fortran 2008 and compiling it with gfortran on my M1 mac. When trying to compile it, I get this error:
Undefined symbols for architecture arm64:
  "___mymodule_MOD_myfunc", referenced from:
      _MAIN__ in cca7mVdW.o
  "___mymodule_MOD_mysub", referenced from:
      _MAIN__ in cca7mVdW.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
My gfortran version:
GNU Fortran (Homebrew GCC 12.1.0) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
The error only occurs when I use a function or subroutine from a different file.
example.f08
program myProgram
    use myModule
    implicit none
    
    integer :: myInteger = 10
    real :: myFloat = 5.2
    complex :: myTuple = (1.0, -0.5)
    character :: myChar = "E"
    character(len=5) :: myString = "Hello"
    logical :: myBool = .true.
    print *, myInteger
    print *, myFloat
    print *, myTuple
    print *, myChar
    print *, myString
    print *, myBool
    print *
    print *, myInteger
    ! From the module "myModule"
    myInteger = myFunc(myInteger)
    print *, myInteger
    ! Also from the module "myModule"
    call mySub(myInteger)
end program myProgram
module.f08:
module myModule
    implicit none
    private
    public myFunc, mySub
    
contains
    integer function myFunc(input) result(output)
        integer, intent(in) :: input
        output = input + 1
    end function myFunc
    subroutine mySub(input)
        integer, intent(in) :: input
        print *, input - 1
    end subroutine mySub
end module myModule
 
    