Compiling Programs with Multiple Source Files

To compile programs that use more than one source file, specify all the filenames on the command line. For example, to compile a program with three source files (mainprog.c, subs1.c, and subs2.c), type:

   icc mainprog.c subs1.c subs2.c

The source file containing the main module can be anywhere in the list. The executable output file will have the same name as the first source file but with the extension .exe. In the example above, the executable file will be mainprog.exe.

You can compile a combination of C and C++ files. There are two ways to specify the file type.

    icc  cprog.c cppprog.cpp cxxprog.cxx othprog.oth
    icc  /Tc cprog.cpp cppprog.cpp /Tp cxxprog.c

cprog.cpp is compiled as a C file, and cppprog.cpp and cxxprog.c are compiled as C++ files.


Summary of Compiler Options