This topic provides some examples of valid ifort commands. It also shows various ways to compile and link source files.
Compiling and Linking
a Single Source File
The following command compiles x.for, links, and creates an executable file. This command generates a temporary object file, which is deleted after linking:
ifort x.for
To specify a particular name for the executable file, specify the -o (Linux* and Mac OS*) or /exe (Windows*) option:
ifort x.for -o myprog.out
(Linux and Mac OS)
ifort x.for /exe:myprog.exe (Windows)
The following command compiles x.for and generates the object file x.o (Linux and Mac OS) or x.obj (Windows). The c option prevents linking (it does not link the object file into an executable file):
ifort -c x.for (Linux and
Mac OS)
ifort x.for /c (Windows)
The following command links x.o or x.obj into an executable file. This command automatically links with the default Intel Fortran libraries:
ifort x.o
(Linux and Mac OS)
ifort x.obj (Windows)
The following command compiles a.for, b.for, and c.for. It creates three temporary object files, then links the object files into an executable file named a.out (on Linux and Mac OS) or a.exe (Windows):
ifort
a.for b.for c.for
When you use modules and compile multiple files, compile the source files that define modules before the files that reference the modules (in USE statements).
When you use a single ifort command, the order in which files are placed on the command line is significant. For example, if the free-form source file moddef.f90 defines the modules referenced by the file projmain.f90, use the following command:
ifort
moddef.f90 projmain.f90