2

As the title says, VS Code is not recognizing cl compiler although opened via Visual Studio 2022 Developer Command Prompt:
VS Developer Command Prompt

VS Code terminal:
enter image description here

I have tried using VS Code external terminal with
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
which did not work.

Setting the comspec manualy in the terminal did solve the issue for the terminal instance:
enter image description here

But the C++ extension is still complaining about cl.exe:
cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS.

I have never used VS Code for C++ before and I don't use windows for development at all so go easy on me.

What could be the reason for the issue and how it can be solved?

Dima Maligin
  • 1,386
  • 2
  • 15
  • 30

2 Answers2

0

Visual Studio Developer Command Prompt must be elevated(run as Administrator) in order to correctly open VS Code with the needed permissions.

Running Visual Studio Developer Command Prompt as Admin solves the issue.

Dima Maligin
  • 1,386
  • 2
  • 15
  • 30
0

One solution that worked for me is to go directly in the setting for C++ extension and find compiler path setting, and manually set it to cl.exe path on your computer.

rezeli
  • 143
  • 2