get "undefined reference" with routines contained in a module
- From: "Hani Andreas Ibrahim" <hani.i@xxxxxxxxxxx>
- Date: Tue, 28 Feb 2006 19:16:38 +0100
Hi,
I have two files, one is a module which *contains* (internal) functions and subroutines, the other is a main program:
file 1:
MODULE mod
[declaration part]
CONTAINS
SUBROUTINE func1()
[code]
END SUBROUTINE func1
END MODULE mod
file 2:
PROGRAM test
USE mod
CALL func1()
END PROGRAM test
If I compile/link both files at the same time, as:
g95 mod.f90 test.f90
I get the expected result, but if I compile the files separately, first
g95 -c mod.f90
and then the main program with
g95 test.f90
I get a "undefined reference" error. My goal is to use modules like libraries in F77 times: Compile modules with internal routines, put the *.mod files into the lib directory (e.g.) and use them with the "-I" option as a library for other main programs. Unfortunately only the declaration part is visible in the separate compiled main program. The contained routine part is not.
Do I have to use interface blocks to reach my goal although I used internal functions/subroutines? BTW: The subroutines don't contain user-defined data types, etc which would need interface blocks.
Do I have to write a single module with the public declaration part and all interface blocks of all (external) functions/subroutines. Write external subroutines/functions with the USE statement of the single module mentioned above. Make a library of these subroutines/functions. Use the USE statement in the main program.
Or maybe I haven't understood the new module architecture of Fortran 90 correctly.
Best regards,
Hani
.
- Follow-Ups:
- Re: get "undefined reference" with routines contained in a module
- From: Michael Metcalf
- Re: get "undefined reference" with routines contained in a module
- From: Steven G. Kargl
- Re: get "undefined reference" with routines contained in a module
- Prev by Date: Re: Python for Fortran programmers
- Next by Date: Re: get "undefined reference" with routines contained in a module
- Previous by thread: Actual argument is incompatible with dummy argument
- Next by thread: Re: get "undefined reference" with routines contained in a module
- Index(es):
Relevant Pages
|
|