
Msvc Cl
- 361 installs
- 155 repo stars
- Updated June 27, 2026
- mohitmishra786/low-level-dev-skills
msvc-cl is a Claude Code skill that guides developers through compiling and linking Windows-native C/C++ with MSVC cl/link, SDK version selection, PDB debug output, and MSVC-specific flags for Visual Studio and headless
About
msvc-cl is a low-level Windows build skill for developers who need MSVC cl.exe and link.exe instead of GCC or Clang. The skill covers SDK version management, PDB debug symbol generation, and MSVC-specific compiler and linker flags for Visual Studio projects and headless CI pipelines on Windows runners. Developers reach for msvc-cl when porting native code, debugging release builds, or configuring automated Windows compilation where incorrect flags or missing PDBs break production diagnostics. The skill targets engineers shipping Windows desktop services, game middleware, or native extensions who must reason about MSVC toolchains without hand-waving generic C++ advice.
- cl/link flag recipes
- PDB and debug symbol flow
- SDK and toolset selection
- /W4 warning hygiene
- CI vcvars automation
Msvc Cl by the numbers
- 361 all-time installs (skills.sh)
- +22 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #154 of 550 CLI & Terminal skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill msvc-clAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 361 |
|---|---|
| repo stars | ★ 155 |
| Last updated | June 27, 2026 |
| Repository | mohitmishra786/low-level-dev-skills ↗ |
How do you compile C/C++ with MSVC cl in CI?
Compile and link Windows-native C/C++ with MSVC cl/link, manage SDK versions, PDB debug info, and MSVC-specific flags for Visual Studio and headless CI agents.
Who is it for?
Windows C/C++ developers configuring MSVC builds in Visual Studio or headless CI agents who need correct cl/link flags and PDB output.
Skip if: Developers building cross-platform projects with CMake and GCC or Clang only, or teams without any Windows native compilation requirement.
When should I use this skill?
The user asks about MSVC cl.exe, link.exe, Windows SDK versions, PDB files, or MSVC compiler flags for C/C++ builds.
What you get
MSVC compile and link command lines, SDK version pins, PDB debug settings, and CI-ready build flag documentation.
- MSVC compile and link command lines
- PDB debug configuration
- SDK version documentation
Files
MSVC cl.exe and clang-cl
Purpose
Guide agents through Windows C/C++ compilation: MSVC cl.exe, clang-cl as MSVC-compatible driver, MSBuild project settings, and runtime library choices.
Triggers
- "How do I compile with MSVC from the command line?"
- "What is the MSVC equivalent of
-O2?" - "/MT vs /MD — which do I use?"
- "How do I use clang-cl instead of cl.exe?"
- "I'm getting LNK errors on Windows"
- "How do I generate PDB files?"
Workflow
1. Set up the environment
MSVC requires the Visual Studio environment variables. Use the Developer Command Prompt or set up manually:
REM x64 native
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
REM x86 cross (host x64, target x86)
"...\vcvarsamd64_x86.bat"
REM Check compiler version
cl /?In CMake, use the "Visual Studio 17 2022" generator or pass -DCMAKE_GENERATOR="Visual Studio 17 2022".
2. Flag translation: GCC → MSVC
| GCC/Clang | MSVC cl.exe | Notes |
|---|---|---|
-O0 | /Od | Debug, no optimisation |
-O1 | /O1 | Minimise size |
-O2 | /O2 | Maximise speed |
-O3 | /Ox | Full optimisation |
-Os | /Os | Favour size |
-g | /Zi | PDB debug info |
-g (embedded) | /Z7 | Debug info in object file |
-Wall | /W3 or /W4 | Warning level |
-Werror | /WX | Warnings as errors |
-std=c++17 | /std:c++17 | Standard selection |
-DFOO=1 | /DFOO=1 | Preprocessor define |
-I path | /I path | Include path |
-c | /c | Compile only (no link) |
-o out | /Fe:out.exe or /Fo:out.obj | Output file |
-shared | /LD | Build DLL |
-fPIC | (implicit on Windows) | Not needed on Windows |
-flto | /GL (compile) + /LTCG (link) | Whole program optimisation |
3. Runtime library selection
This is the most common source of LNK errors on Windows.
| Flag | Runtime | Use case |
|---|---|---|
/MD | MSVCRT.dll (dynamic) | Release, DLL linkage (recommended default) |
/MDd | MSVCRTd.dll (debug dynamic) | Debug builds |
/MT | Static CRT | Standalone exe; avoid mixing with DLLs |
/MTd | Static CRT debug | Debug + static |
Rule: All objects and libraries in a link must use the same runtime. Mixing /MT and /MD causes LNK2038: mismatch detected.
4. clang-cl
clang-cl is Clang's MSVC-compatible driver. It accepts cl.exe-style flags and can replace cl.exe in most MSBuild/CMake projects.
REM Install: part of LLVM Windows release or VS "LLVM" component
REM Basic usage (MSVC-style flags)
clang-cl /O2 /std:c++17 /MD src.cpp /Fe:prog.exe
REM Pass Clang-native flags with /clang:
clang-cl /O2 /clang:-Rpass=inline src.cpp /Fe:prog.exe
REM Use in CMake
cmake -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl ..Minimum Clang version for MSVC STL compatibility: Clang 8+. For C++20 features with MSVC STL: Clang 14+.
Source: <https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild>
5. PDB files and debugging
REM Compile with /Zi (external PDB) and /Fd (PDB name)
cl /Zi /Fd:prog.pdb /O2 src.cpp /link /DEBUG
REM /Z7: debug info embedded in .obj (no separate PDB for objects)
cl /Z7 /O2 src.cpp /link /DEBUG /PDB:prog.pdbFor WinDbg or VS debugger, ensure the PDB is alongside the executable or set the symbol path.
6. Common LNK errors
| Error | Cause | Fix |
|---|---|---|
LNK2019: unresolved external | Missing .lib | Add library in project settings or /link foo.lib |
LNK2038: mismatch detected for 'RuntimeLibrary' | Mixed /MT and /MD | Unify all to /MD or /MT |
LNK1104: cannot open file 'foo.lib' | Library not in search path | Add path via /LIBPATH: or LIB env var |
LNK2005: already defined | Multiple definitions | Use __declspec(selectany) or check for duplicate definitions |
LNK4098: defaultlib 'LIBCMT' conflicts | Runtime mismatch | Explicitly pass /NODEFAULTLIB:LIBCMT or unify runtimes |
7. Useful cl.exe flags
REM Preprocessed output
cl /P src.cpp # produces src.i
REM Assembly output
cl /FA /O2 src.cpp # produces src.asm (MASM syntax)
cl /FAs # interleave source + asm
REM Show include files
cl /showIncludes src.cpp
REM Compiler version
cl /? 2>&1 | findstr /i "version"For flag details, see references/flags.md.
Related skills
- Use
skills/compilers/clangfor clang-cl's Clang-native diagnostics - Use
skills/build-systems/cmakefor CMake toolchain configuration on Windows - Use
skills/debuggers/lldbor WinDbg for debugging MSVC-built binaries
MSVC cl.exe Flag Reference
Source: <https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options> Source: <https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild>
Optimisation
| Flag | Effect |
|---|---|
/Od | Disable optimisation (debug) |
/O1 | Minimise size |
/O2 | Maximise speed (recommended release) |
/Ox | Full optimisation (like -O3) |
/Os | Favour code size |
/Ot | Favour code speed |
/GL | Whole-program optimisation (LTO compile phase) |
/fp:fast | Unsafe FP optimisations |
/fp:precise | Default FP |
/fp:strict | Strict FP semantics |
Link with /LTCG when using /GL.
Debug information
| Flag | Effect |
|---|---|
/Zi | External PDB (recommended) |
/Z7 | Embed debug info in .obj |
/Zd | Line numbers only |
/Fd:name.pdb | Name the PDB file |
/DEBUG | Linker: generate PDB |
/DEBUG:FULL | Full debug symbols |
/DEBUG:FASTLINK | Faster link, requires PDB at debug time |
Runtime libraries
| Flag | Library | Type |
|---|---|---|
/MD | MSVCRT.dll | Release dynamic |
/MDd | MSVCRTd.dll | Debug dynamic |
/MT | libcmt.lib | Release static |
/MTd | libcmtd.lib | Debug static |
All TUs in a link must use the same choice.
Warnings
| Flag | Effect |
|---|---|
/W0 | No warnings |
/W1 | Severe warnings |
/W2 | Significant warnings |
/W3 | Production quality (default) |
/W4 | Informational warnings |
/Wall | All warnings (very noisy) |
/WX | Warnings as errors |
/wd4100 | Disable warning C4100 |
/we4239 | Treat C4239 as error |
/analyze | Static analysis |
Standards
| Flag | Standard |
|---|---|
/std:c++14 | C++14 |
/std:c++17 | C++17 |
/std:c++20 | C++20 |
/std:c++latest | Latest preview features |
/std:c11 | C11 |
/std:c17 | C17 |
/Za | Disable Microsoft extensions |
/permissive- | Standards conformance mode (recommended) |
Output control
| Flag | Effect |
|---|---|
/c | Compile only |
/Fe:name | Executable name |
/Fo:name | Object file name |
/FA | Assembly listing |
/FAs | Interleaved source + asm |
/P | Preprocessed output (.i) |
/showIncludes | Print include tree |
Linking (passed after /link)
| Flag | Effect |
|---|---|
/SUBSYSTEM:CONSOLE | Console app |
/SUBSYSTEM:WINDOWS | GUI app |
/DLL | Build DLL |
/ENTRY:fn | Custom entry point |
/LTCG | Link-time code generation (pairs with /GL) |
/INCREMENTAL:NO | Disable incremental linking |
/LIBPATH:path | Additional library search path |
/NODEFAULTLIB:lib | Exclude a default library |
Related skills
How it compares
Pick msvc-cl when the build target is Windows-native MSVC toolchains; use generic C++ or CMake skills for cross-platform GCC or Clang workflows.
FAQ
What does the msvc-cl skill help with?
The msvc-cl skill helps developers compile and link Windows-native C/C++ using MSVC cl and link, manage Windows SDK versions, configure PDB debug output, and set MSVC-specific flags for Visual Studio and headless CI agents.
When should I use msvc-cl instead of generic C++ advice?
Use msvc-cl when builds must run on Windows with MSVC cl.exe and link.exe, including SDK pinning, PDB generation, and linker flags that differ from GCC or Clang toolchains in CI pipelines.