Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Invoke the Compiler

Requirements Before Using the Command Line

You may need to set certain environment variables before using the command line. For more information, see Specify the Location of Compiler Components.

Different Compilers and Drivers

The table below provides the different compiler front-end and driver information.

Compiler Notes Linux Driver Windows Driver

Intel® C++ Compiler Classic

A C++ compiler that supports an OpenMP but not OpenMP offload.

icc for C

icpc for C++

icl

Use the Compiler from the Command Line

Use the compiler with the OS/language specific invocations below.

Linux

Invoke the compiler using icc/icpc to compile C/C++ source files.

  • When you invoke the compiler with icc the compiler builds C source files using C libraries and C include files. If you use icc with a C++ source file, it is compiled as a C++ file. Use icc to link C object files.
  • When you invoke the compiler with icpc the compiler builds C++ source files using C++ libraries and C++ include files. If you use icpc with a C source file, it is compiled as a C++ file. Use icpc to link C++ object files.

The icc/icpc command:

  • Compiles and links the input source file(s).
  • Produces one executable file, a.out, in the current directory.

macOS:

Invoke the compiler using icc or icpc to compile C/C++ source files.

  • When you invoke the compiler with icc, the compiler builds C source files using C libraries and C include files. If you use icc with a C++ source file, it is compiled as a C++ file. Use icc to link C object files.
  • When you invoke the compiler with icpc the compiler builds C++ source files using C++ libraries and C++ include files (libc++ library is used by default). If you use icpc with a C source file, it is compiled as a C++ file. Use icpc to link C++ object files.

The icc/icpc command:

  • Compiles and links the input source file(s).
  • Produces one executable file, a.out, in the current directory.

Windows

You can invoke the compiler on the command line using icl. This command:

  • Compiles and links the input source file(s).
  • Produces object file(s) and assigns the names of the respective source file(s), but with a .obj extension.
  • Produces one executable file and assigns it the name of the first input file on the command line, but with a .exe extension.
  • Places all the files in the current directory.

When compilation occurs with the compiler, many tools may be called to complete the task that may reproduce diagnostics unique to the given tool. For instance, the linker may return a message if it cannot resolve a global reference.

Command Line Syntax

The syntax to invoke the compiler is:

Linux and macOS

icc [option] file1 [file2...]

Windows

icl [option] file1 [file2...]

Argument

Description

option

Indicates one or more command line options. On Linux and macOS systems, the compiler recognizes one or more letters preceded by a hyphen (-). On Windows, options are preceded by a hyphen (-) or slash (/). This includes linker options.

Options are not required when invoking the compiler. The default behavior of the compiler implies that some options are ON by default when invoking compiler.

file1, file2...

Indicates one or more files to be processed by the compiler.

/link (Windows)

All options following /link are passed to the linker. Compiler options must precede link if they are not to be passed to the linker.

Other Methods for Using the Command Line to Invoke the Compiler

  • Using makefiles from the Command Line: Use makefiles to specify a number of files with various paths and to save this information for multiple compilations. For more information on using makefiles, see Use Makefiles to Compile Your Application.
  • Using a Batch File from the Command Line: Create and use a .bat file to execute the compiler with a desired set of options instead of retyping the command each time you need to recompile.