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.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.
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:| Command | Keyboard | What it Does |
|---|---|---|
| Build Solution | Ctrl+Shift+B | Compiles and links all projects in the solution that are out of date |
| Build Project | Ctrl+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 File | Ctrl+F7 | Compiles only the file currently open in the editor |
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.Watch the Output Window
The Output window (open it with View > Output) streams build progress in real time:A “succeeded” summary with 0 failures means your binary is ready. The full path to the output
.exe is shown on the third line.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.,
C2065for “undeclared identifier”) - Description: Human-readable explanation
- File and Line: Click to jump directly to the problem in the editor
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.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.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 ofmain().
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: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.
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.
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.
Step Through Code
Use these keyboard shortcuts to control execution line by line:
| Key | Command | Description |
|---|---|---|
| F10 | Step Over | Execute the current line; if it calls a function, run the whole function |
| F11 | Step Into | Execute the current line; if it calls a function, enter that function |
| Shift+F11 | Step Out | Run until the current function returns |
| F5 | Continue | Resume running until the next breakpoint or program exit |
| Shift+F5 | Stop Debugging | Terminate the process and end the debug session |
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)— source file and line numbererror— severity (can also bewarningornote)C2065— error code (searchable in the documentation)'xyz': undeclared identifier— human-readable description
| Error | Meaning |
|---|---|
C2065 | Used a variable or function name that hasn’t been declared |
C2143 | Syntax error — missing semicolon, brace, or parenthesis |
C4996 | Used a function marked as deprecated |
LNK2019 | Unresolved external symbol — declared but not defined or library not linked |
LNK1120 | One 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
x64\Debug\. You can run it from a Command Prompt or the Developer Command Prompt:
cl.exe and link.exe directly.