Share via

CL environment variables

The CL tool uses the following environment variables:

  • CL and _CL_, if defined. The CL tool prepends the options and arguments defined in the CL environment variable to the command-line arguments, and appends the options and arguments defined in _CL_, before processing.

  • INCLUDE, which must point to the \include subdirectory of your Visual Studio installation.

  • LIBPATH, which specifies directories to search for metadata files referenced with #using. For more information on LIBPATH, see #using.

You can set the CL or _CL_ environment variable using the following syntax:

SET CL=[ [option] ... [file] ...] [/link link-opt ...]
SET _CL_=[ [option] ... [file] ...] [/link link-opt ...]

For details on the arguments to the CL and _CL_ environment variables, see MSVC Compiler Command-Line Syntax.

You can use these environment variables to define the files and options you use most often. Then use the command line to give more files and options to CL for specific purposes. The CL and _CL_ environment variables are limited to 1024 characters (the command-line input limit).

You can't use the /D option to define a symbol that uses an equal sign (=). Instead, you can use the number sign (#) for an equal sign. In this way, you can use the CL or _CL_ environment variables to define preprocessor constants with explicit values—for example, /DDEBUG#1 to define DEBUG=1.

For more information, see Use the MSVC toolset from the command line.


The following command is an example of setting the CL environment variable:


When the CL environment variable is set, if you enter CL INPUT.C at the command line, the effective command becomes:


The following example causes a plain CL command to compile the source files FILE1.c and FILE2.c, and then link the object files FILE1.obj, FILE2.obj, and FILE3.obj:


These environment variables make the call to CL have the same effect as the following command line:


See also

Setting Compiler Options
MSVC Compiler Options