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

Trying to compile program with use module on command line


I have 2 .f90 files.

file: mod_def.f90 

module definedmod
integer :: a = 4
end module definedmod

file: use_mod_def.f90

program usemod
use definedmod
	print *, a
end program usemod

I succeeded in compiling the module definition file using this command:

ifort -c mod_def.f90

THis generated a .obj and .mod file which is good. However when I try to compile the main program

ifort use_mod_def.f90

I get a big error

D:\TEMP\TRUNK-IFORT\test>ifort use_mod_def.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Inte
l(R) 64, Version Build 20121008
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

use_mod_def.obj : error LNK2019: unresolved external symbol DEFINEDMOD_mp_A refe
renced in function MAIN__
use_mod_def.exe : fatal error LNK1120: 1 unresolved externals

How do I compile the main program and have it recognize the use module?

As a side notes the online help docs don't  provide a working example. They only gloss over some generalities. It would be good to have working examples that users can copy, paste and work with...

Thanks and look forward to your responses.


0 Kudos
1 Reply

Nevermind I got it from this thread

what I did was:

>ifort -c mod_def.f90

>ifort use_mod_def.f90 mod_def.obj

Then I got the executable.