# nvcc fatal   : Cannot find compiler 'cl.exe' in PATH

- **ID:** `cuda/nvcc-include-path-not-found`
- **Domain:** cuda
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

On Windows, nvcc requires the Microsoft Visual C++ compiler (cl.exe) to be in the PATH, but the build environment is missing the necessary Visual Studio tools or the correct architecture (x64 vs x86) is not configured.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CUDA 12.0 | active | — | — |
| CUDA 11.8 | active | — | — |
| Visual Studio 2022 | active | — | — |
| Visual Studio 2019 | active | — | — |

## Workarounds

1. **Open the 'x64 Native Tools Command Prompt for VS 2022' (or VS 2019) from the Start Menu, then run your nvcc command from that prompt. This sets all required environment variables automatically.** (95% success)
   ```
   Open the 'x64 Native Tools Command Prompt for VS 2022' (or VS 2019) from the Start Menu, then run your nvcc command from that prompt. This sets all required environment variables automatically.
   ```
2. **If using a build system like CMake, set the `CMAKE_GENERATOR` to 'Visual Studio 17 2022' and specify `-A x64` to ensure the correct toolchain is used.** (85% success)
   ```
   If using a build system like CMake, set the `CMAKE_GENERATOR` to 'Visual Studio 17 2022' and specify `-A x64` to ensure the correct toolchain is used.
   ```
3. **Manually add the Visual C++ compiler directory to PATH: `set PATH=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64;%PATH%` (adjust version numbers). Also set INCLUDE and LIB as per VS developer prompt.** (75% success)
   ```
   Manually add the Visual C++ compiler directory to PATH: `set PATH=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64;%PATH%` (adjust version numbers). Also set INCLUDE and LIB as per VS developer prompt.
   ```

## Dead Ends

- **Reinstalling CUDA Toolkit without Visual Studio** — The error is about the missing Visual Studio compiler, not CUDA itself; reinstalling CUDA does not add cl.exe to PATH. (95% fail)
- **Setting PATH to a random directory containing cl.exe from a different architecture (e.g., x86 instead of x64)** — nvcc requires the x64 native tools; using x86 cl.exe causes link errors or wrong object file format. (80% fail)
- **Installing only the 'Desktop development with C++' workload but not launching from the correct developer command prompt** — The environment variables (INCLUDE, LIB, PATH) are only set in the Visual Studio developer command prompt; a regular cmd or PowerShell does not inherit them. (75% fail)
