0

I've recently been trying to compile some C++ code using the cl command in a VS Code terminal. I am running VS Code inside of the developer terminal and still getting the error. I have tried to re-install VS Code and VS Community, still no luck. I have also double checked to make sure that cl.exe is installed.

I'm clearly missing something here, so any help would be greatly appreciated.

cap
  • 117
  • 1
  • 2
  • 7
  • 1
    You should run cl.exe from the visual studio developer command prompt. Or run a bat file prior cl.exe. All information https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160 – 273K Jun 30 '21 at 01:40
  • Do you use a `c_cpp_properties.json` file? What's its contents if you do? Also have you read https://code.visualstudio.com/docs/cpp/config-msvc#_cc-configurations ? – Timothy G. Jun 30 '21 at 01:44
  • [This Answer](https://stackoverflow.com/a/74578920/1147688) will most likely help you. – not2qubit Nov 26 '22 at 00:48

1 Answers1

1

You should run VS Code from the developer command prompt.

https://code.visualstudio.com/docs/cpp/config-msvc#_troubleshooting

The term 'cl.exe' is not recognized

If you see the error "The term 'cl.exe' is not recognized as the name of a cmdlet, function, script file, or operable program.", this usually means you are running VS Code outside of a Developer Command Prompt for Visual Studio and VS Code doesn't know the path to the cl.exe compiler.

You can always check that you are running VS Code in the context of the Developer Command Prompt by opening a new Terminal (Ctrl+Shift+`) and typing 'cl' to verify cl.exe is available to VS Code.

273K
  • 29,503
  • 10
  • 41
  • 64
  • 1
    As I mentioned in my post, I am already running it out of the developer command prompt – cap Jun 30 '21 at 13:53
  • "I am running VS Code out of the developer terminal" means the opposite. – 273K Jun 30 '21 at 13:58
  • Oh sorry I can see the confusion there, what I meant to say was that I am running VS Code using the developer terminal. My bad. – cap Jun 30 '21 at 14:04
  • Have you tried to run cl.exe in the developer command prompt? Maybe you did not install the compiler toolset? – 273K Jun 30 '21 at 14:16