Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MicrosoftDocs/cpp-docs/llms.txt

Use this file to discover all available pages before exploring further.

Once you have a C++ project set up in Visual Studio, the build-run-debug cycle is the core workflow you will repeat hundreds of times per day. Visual Studio makes this fast and transparent: a single keyboard shortcut compiles all your source files, links the result, and reports any problems through dedicated windows. This page covers the full workflow — building, interpreting compiler output, running with and without the debugger, and understanding what each IDE window tells you.

Building Your Project

Building means compiling all source files that have changed since the last build and linking them into an output binary. Visual Studio provides several build commands:
CommandKeyboardWhat it Does
Build SolutionCtrl+Shift+BCompiles and links all projects in the solution that are out of date
Build ProjectCtrl+B (when project selected)Builds only the currently selected project
Rebuild Solution(menu only)Deletes all outputs and rebuilds everything from scratch
Clean Solution(menu only)Deletes all compiled outputs without building
Compile FileCtrl+F7Compiles only the file currently open in the editor
For most day-to-day work, Ctrl+Shift+B (Build Solution) is the command you want. It only recompiles files that have changed, so subsequent builds after the first are much faster.
1

Trigger a Build

With your HelloWorld project open, press Ctrl+Shift+B or go to Build > Build Solution. Visual Studio saves any unsaved files and begins compilation.
2

Watch the Output Window

The Output window (open it with View > Output) streams build progress in real time:
Build started...
1>------ Build started: Project: HelloWorld, Configuration: Debug x64 ------
1>HelloWorld.cpp
1>HelloWorld.vcxproj -> C:\Users\you\source\HelloWorld\x64\Debug\HelloWorld.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
A “succeeded” summary with 0 failures means your binary is ready. The full path to the output .exe is shown on the third line.
3

Check the Error List for Problems

If there are compiler errors or warnings, they appear in the Error List window (Ctrl+\, E or View > Error List). Each entry shows:
  • Type: Error (red), Warning (yellow), or Message (blue)
  • Code: The error/warning number (e.g., C2065 for “undeclared identifier”)
  • Description: Human-readable explanation
  • File and Line: Click to jump directly to the problem in the editor
Double-clicking any entry in the Error List opens the file at the offending line and places the cursor there.

Understanding Build Configurations

Visual Studio builds in one of several configurations, selectable from the dropdown in the toolbar (next to the green play button):

Debug

The default for active development. Disables optimizations (/Od), generates full debug symbols (.pdb file), enables runtime checks, and produces a binary in x64\Debug\. Edit and Continue works in this mode.

Release

For shipping. Enables full optimizations (/O2 or /Ox), omits most debug symbols, and produces a smaller, faster binary in x64\Release\. Always test your Release build before shipping.
Always develop and debug in the Debug configuration. Switch to Release to measure performance benchmarks and before producing binaries for end users.

Running Your Application

After a successful build, there are two ways to run your application from within Visual Studio:

Start Without Debugging (Ctrl+F5)

Ctrl+F5 (or Debug > Start Without Debugging) launches your executable directly, without attaching the Visual Studio debugger. For console applications, this is the recommended way to run — the console window stays open after the program exits, displaying a “Press any key to continue…” prompt so you can read the output.
Hello World!

C:\...\HelloWorld\x64\Debug\HelloWorld.exe (process 12345) exited with code 0.
Press any key to close this window . . .

Start Debugging (F5)

F5 (or Debug > Start Debugging) launches the executable with the Visual Studio debugger attached. The program runs at full speed until it hits a breakpoint, an exception, or exits. For console apps, the console window closes immediately when the program ends unless you set a breakpoint near the end of main().
Use F5 when you want to step through code or inspect variable values. Use Ctrl+F5 when you just want to see the program’s output.

Debugging Basics

The Visual Studio debugger is one of the most powerful features of the IDE. Here are the fundamental operations:
1

Set a Breakpoint

Click in the gray margin to the left of a line number in the source editor — a red dot appears. Alternatively, place your cursor on the line and press F9. When the debugger reaches that line during execution (via F5), it pauses before executing it.
2

Run to the Breakpoint

Press F5 to start debugging. Execution pauses at your breakpoint. The yellow arrow in the margin shows the current execution position.
3

Inspect Variables

With execution paused, hover your mouse over any variable in the editor to see its current value in a tooltip. Use the Autos window (auto-shown when debugging) to see variables used near the current line. Use the Locals window to see all local variables in the current function. Use Watch windows (Debug > Windows > Watch) to pin specific expressions.
4

Step Through Code

Use these keyboard shortcuts to control execution line by line:
KeyCommandDescription
F10Step OverExecute the current line; if it calls a function, run the whole function
F11Step IntoExecute the current line; if it calls a function, enter that function
Shift+F11Step OutRun until the current function returns
F5ContinueResume running until the next breakpoint or program exit
Shift+F5Stop DebuggingTerminate the process and end the debug session
5

Edit and Continue

MSVC supports Edit and Continue: you can modify source code while the debugger is paused and apply changes without restarting the debug session. After editing, press F5 to continue — the debugger recompiles only the changed function. This requires the Debug configuration and the /ZI compile flag (enabled by default in Debug builds).

Reading Compiler Errors

MSVC error messages follow a predictable format:
HelloWorld.cpp(8): error C2065: 'xyz': undeclared identifier
  • HelloWorld.cpp(8) — source file and line number
  • error — severity (can also be warning or note)
  • C2065 — error code (searchable in the documentation)
  • 'xyz': undeclared identifier — human-readable description
Common errors and what they mean:
ErrorMeaning
C2065Used a variable or function name that hasn’t been declared
C2143Syntax error — missing semicolon, brace, or parenthesis
C4996Used a function marked as deprecated
LNK2019Unresolved external symbol — declared but not defined or library not linked
LNK1120One or more unresolved externals (summary of LNK2019 errors)

Running from the Command Line

After Visual Studio builds your project, the executable lives at:
  • Debug: <SolutionDir>\x64\Debug\HelloWorld.exe
  • Release: <SolutionDir>\x64\Release\HelloWorld.exe
To find it quickly, right-click the solution in Solution Explorer and choose Open Folder in File Explorer, then navigate into x64\Debug\. You can run it from a Command Prompt or the Developer Command Prompt:
cd "C:\Users\you\source\HelloWorld\x64\Debug"
HelloWorld.exe
Output:
Hello World!
The Developer Command Prompt for Visual Studio (available in the Start menu) also sets up the build environment so you can invoke cl.exe and link.exe directly.

Build docs developers (and LLMs) love