This documentation is archived and is not being maintained.

Building on the Command Line

Visual C++ provides command-line tools for programmers who prefer to build their applications from the command prompt. If you want to use the command line to build a project created in Visual C++, you can use one of the following:


Use the compiler (cl.exe) to compile and link source code files.


Use the linker (link.exe) to link compiled object files.

MSBuild (Visual C++)

Use MSBuild to build Visual C++ projects and Visual Studio solutions from the command line. Invoking this utility is equivalent to running the Build project or Build Solution command in the Visual Studio integrated development environment.


Use DEVENV combined with a command line switch, such as /Build or /Clean, to perform certain build commands without displaying the Visual Studio IDE.


Use NMake to automate tasks that build Visual C++ projects.

When you build from the command line, you can obtain help on warnings, errors, and messages by starting the development environment and clicking Search on the Help menu.

Walkthrough: Compiling a Native C++ Program on the Command Line

Describes how to compile a C++ program from the command line.

Walkthrough: Compiling a C Program

Describes how to compile a program written in the C programming language.

Walkthrough: Compiling a C++ Program that Targets the CLR in Visual Studio

Describes how to compile a C++/CLI program that targets the .NET Framework.

Setting the Path and Environment Variables for Command-Line Builds

Describes using VCVARS32.BAT to set the path and environment variables.

NMAKE Reference

Provides links to topics discussing the Microsoft Program Maintenance Utility (NMAKE.EXE).

MSBuild (Visual C++)

Provides links to topics that discuss MSBuild.EXE.

/MD, /MT, /LD (Use Run-Time Library)

Describes using these compiler options to use a Debug or Release run-time library.

C/C++ Compiler Options

Provides links to topics discussing the C and C++ compiler options and CL.EXE.

Linker Options

Provides links to topics that discuss the linker options and LINK.EXE.

C/C++ Build Tools

Provides links to the C/C++ build tools provided with Visual C++.

Building a C/C++ Program

Provides links to topics that describe building your program from the command line or from the Visual Studio IDE.