Practical guide Visual Studio C++
Speed up C++ builds in Visual Studio
Most slow C++ builds come from a few settings: files compiled one at a time, headers parsed again in every file, and Release options in Debug. Measure first, then change the settings that matter.
Visual Studio property-page paths describe MSBuild projects. For CMake, configure the corresponding target or preset. Menu names can vary by Visual Studio version; use the cited reference for your toolset.
Transcript
The build settings that slow a C++ project, found and fixed by CppPilot in Visual Studio. Renderer builds slowly.
Choose Extensions > CppPilot > Project & Solution > Build Performance and Modernization. CppPilot checks the settings that cost build time, as Visual Studio evaluates them, and the AI confirms each candidate in the project file.
Two findings. The five source files compile one after another: turn on parallel compilation, /MP.
And Debug links without incremental linking. A third candidate is dropped, with the reason.
Click Fix review findings. The AI changes the project file: /MP on, and incremental linking back in Debug.
Visual Studio reloads the project. Build again: the files now compile in parallel, and later edits link incrementally.
CppPilot explains and fixes C++ build errors in Visual Studio.
- MeasureBuild output / Build Insights
- LocateCompilation or linking?
- ChangeOne relevant setting
- CompareSame build, same machine
Find the expensive build stage, change one setting, then measure the same build again.
Measure where the time goes
Set Tools > Options > Projects and Solutions > VC++ Project Settings > Build Timing to Yes: the Build output then shows the time of each project and each step. For details per file and per header, run Build Insights (Build > Run Build Insights in Visual Studio 2022 17.8 and later): it shows the files that take longest to compile and the headers included most often.
Compile files in parallel
For MSBuild C++ projects, check C/C++ > General > Multi-processor Compilation (/MP):
it lets an MSVC compiler invocation compile multiple source files in parallel. It may already be enabled by your project
template. Visual Studio also builds independent MSBuild projects in
parallel: Tools > Options > Projects and Solutions > Build and Run > maximum number of parallel project
builds.
If the compiler then runs out of memory (C1060, C1076, or MSB6006), lower
Maximum concurrent C++ compilations in VC++ Project Settings rather than turning
/MP off.
Schematic only, not a timing measurement. Independent compilations can overlap; memory and CPU limits determine the benefit.
Use a precompiled header
Large headers such as windows.h, the standard library, or Qt and Boost are parsed again in every file that
includes them. A precompiled header parses them once per project. Put stable, heavy headers in pch.h, never
the headers you edit every day: a change to pch.h rebuilds the whole project. See
how to set up precompiled headers.
Include less
Every #include in a header is paid by every file that includes that header. Where a header only uses a
pointer or a reference to a class, forward-declare it (class Widget;) and include its header in the
.cpp file. Build Insights' Included Files view shows which headers cost the most.
Keep Debug builds light
- Whole Program Optimization (
/GLand/LTCG) belongs in Release only: in Debug it delays all code generation to the link. - Linker > General > Enable Incremental Linking should be Yes in Debug, so that a small change relinks quickly.
- Give each project its own Intermediate Directory: projects that share one overwrite each other's files and rebuild more than needed.
Debug: settings to investigate
Whole Program Optimization: Yes (/GL)Incremental Linking: NoIntermediate Directory: obj\Debug: typical development settings
Whole Program Optimization: NoIncremental Linking: Yes (/INCREMENTAL)Intermediate Directory:$(Platform)\$(Configuration)\$(ProjectName)\Check build settings with CppPilot
Right-click the solution and choose CppPilot > Build Performance and Modernization. CppPilot reads the settings Visual Studio evaluates for every configuration, property sheets included, and lists the projects without parallel compilation, large projects without a precompiled header, whole program optimization or no incremental linking in Debug, and shared intermediate directories, each with the property to change.
Sources and scope
Official references
These links document the compiler, build system, or debugger behavior discussed here. Use the version selector on Microsoft Learn for your toolset. Example blocks are focused excerpts; required headers and build settings are stated alongside them.
Using CppPilot in Visual Studio
CppPilot connects your own Codex or Claude account to Visual Studio. If you have neither, CppPilot Cloud provides AI access for build fixes, reviews, crash analysis, and project checks. AI chat requires your own Codex or Claude account.