While learning Fortran, I came across modules and procedures. I wrote the following code and got into an error saying Undefined symbols for architecture arm64
.
Example program: a.f90:
module debug_2
implicit none
interface i
module procedure :: sub_1
module procedure :: sub_2
end interface i
contains
subroutine sub_1(v)
real, intent(in) :: v
print *, "1"
end subroutine sub_1
subroutine sub_2(v)
logical, intent(in) :: v
print *, "2"
end subroutine sub_2
end module debug_2
b.f90
module debug
use debug_2
implicit none
interface i
module procedure :: sub_3
end interface
contains
subroutine sub_3(v)
integer, intent(in) :: v
print *, "3"
end subroutine sub_3
end module debug
program x
use debug
implicit none
integer :: c
logical :: b
real :: a
call i(a)
call i(b)
call i(c)
end program x
After executing the above files, I get
$ gfortran -c a.f90
$ gfortran b.f90
Undefined symbols for architecture arm64:
"___debug_2_MOD_sub_1", referenced from:
_MAIN__ in ccaCj35V.o
"___debug_2_MOD_sub_2", referenced from:
_MAIN__ in ccaCj35V.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
What am I doing wrong here?