Compiling and Linking Intel Fortran/C Programs

Your application can contain both C and Fortran source files. If your main program is a Fortran source file (myprog.for) that calls a routine written in C (cfunc.c), you can use the following sequence of commands to build your application:

icc -c cfunc.c
ifort -o myprog myprog.for cfunc.o

The icc (for Intel C++) command compiles cfunc.c. The -c option specifies that the linker is not called. This command creates cfunc.o. The ifort command compiles myprog.for and links cfunc.o with the object file created from myprog.for to create myprog.

If your C/C++ program calls an Intel Fortran subprogram, specify the option -nofor_main on the ifort command line:

icc -c  cmain.c
ifort -nofor_main cmain.o fsub.f90