Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Interface blocks *.fi

TonyRichards
Novice
226 Views

If I compile a project consisting of routines and functions in different f90 files, I can get warnings having the form

Error error LNK2019: unresolved external symbol _SOMEROUTINEORFUNCTION referenced in function _SOMEFUNCTIONORdlgproc.obj

If every subroutine or function must contain an interface block for each routine or function it might reference, is there a compile option or tool that forces the production of a PROJECT.FI file containing all the necessary prototype interface blocks obtained from the definitions of each function or subroutine that is being compiled? Then an interface module can be constructed that can be included in each Fortran file, taking care of the risk of unresolved externals.

I have looked under Project debug properties...Fortran...Output files and cannot see reference to production of interface blocks.

I note that a recent project folder of mine contained a PROJECT.FI file which contained a single prototype interface block for a function that is nowhere in the project!

TIA

Anthony Richards

0 Kudos
4 Replies
jimdempseyatthecove
Black Belt
216 Views

See: gen-interfaces (intel.com)

Interfaces should be specified in a module and not as an include file (.fi).

Jim Dempsey

 

mecej4
Black Belt
204 Views

Providing interfaces, either in the form of interface blocks in the source code or in include files, or in a module that is then used in other sources where those interfaces are needed, helps the compiler to generate the correct calling sequence. However, the actual subroutines/functions that those interfaces pertain to may be contained in other sources or in libraries. The corresponding OBJ files and/or LIB files must be searched at link time, and you can facilitate that either by modifying the linker command line, or by using OBJCOMMENT directives in your source codes.

Ron_Green
Moderator
193 Views

mecej4 is correct.  to simplify the message: the unresolved symbol warnings have nothing to do with interfaces.  It's link time, not compile time warnings or errors.  Your link phase either is missing libraries or you have other issues with your build (Project Properties)

andrew_4619
Honored Contributor II
174 Views

You really really need to be using modules and sub-modules and all the interface issues will go away and your codes will be much more robust and "self checking". 

Reply