-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linking Error : Calling external function throws undefined refernce error #4008
Comments
same as in #4009 |
@assem2002 the above error occurs because there is no function
program a
implicit none
integer :: c
interface f1
integer function f() result(d)
end function
end interface f1
c = f()
print *, c
end program a
function f() result(d)
integer :: d
d = 9
end function f This gives the required output (base) saurabh-kumar@Awadh:~/Projects/System/lfortran$ lfortran ./examples/example.f90
9 |
For loading the function from an external module, we can do
module func
implicit none
contains
function f() result(d)
integer :: d
d = 9
end function f
end module func
program a
use func
implicit none
integer :: c
c = f()
print *, c
end program a Which gives the output (base) saurabh-kumar@Awadh:~/Projects/System/lfortran$ lfortran ./examples/example.f90
9 |
@kmr-srbh. Yeah you're right about your suggested code.but we should be able to call an external function that's defined in another file using |
@assem2002 could you please share the steps you followed to compile this using GFortran? How does the compiler know where |
assem@assem-PC:~/Desktop/fortran/test_05$ gfortran -c func.f90
assem@assem-PC:~/Desktop/fortran/test_05$ gfortran -c prog.f90
assem@assem-PC:~/Desktop/fortran/test_05$ gfortran -o mmm func.o prog.o
assem@assem-PC:~/Desktop/fortran/test_05$ ./mmm
9
I think it just compiles |
Looks like we are dealing with legacy code here. |
as @Pranavchiku mentioned it would compile normally with |
Calling a function or subroutine from another file throws error.
The text was updated successfully, but these errors were encountered: