Loading...
Loading...
MSVC cl.exe and clang-cl skill for Windows C/C++ projects. Use when configuring Visual Studio builds, MSBuild, or clang-cl as a drop-in MSVC replacement. Covers translating GCC/Clang flags to MSVC equivalents, runtime library selection, Windows SDK setup, and diagnosing MSVC-specific errors. Activates on queries about cl.exe, clang-cl, /O flags, /MT vs /MD, PDB files, Windows ABI, or MSVC project settings.
npx skill4agent add mohitmishra786/low-level-dev-skills msvc-clcl.execlang-cl-O2REM 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 /?-DCMAKE_GENERATOR="Visual Studio 17 2022"| GCC/Clang | MSVC cl.exe | Notes |
|---|---|---|
| | Debug, no optimisation |
| | Minimise size |
| | Maximise speed |
| | Full optimisation |
| | Favour size |
| | PDB debug info |
| | Debug info in object file |
| | Warning level |
| | Warnings as errors |
| | Standard selection |
| | Preprocessor define |
| | Include path |
| | Compile only (no link) |
| | Output file |
| | Build DLL |
| (implicit on Windows) | Not needed on Windows |
| | Whole program optimisation |
| Flag | Runtime | Use case |
|---|---|---|
| | Release, DLL linkage (recommended default) |
| | Debug builds |
| Static CRT | Standalone exe; avoid mixing with DLLs |
| Static CRT debug | Debug + static |
/MT/MDLNK2038: mismatch detectedclang-clcl.execl.exeREM 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 ..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.pdb| Error | Cause | Fix |
|---|---|---|
| Missing | Add library in project settings or |
| Mixed | Unify all to |
| Library not in search path | Add path via |
| Multiple definitions | Use |
| Runtime mismatch | Explicitly pass |
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"skills/compilers/clangskills/build-systems/cmakeskills/debuggers/lldb