This usually means that VS Code cannot find the gcc compiler executable, even if you have installed MinGW. Here’s how to fix it step by step:
- Verify MinGW Installation
Make sure you installed MinGW and included the gcc compiler.
Typically, MinGW is installed in:
C:\MinGW\bin
Open a Command Prompt (not VS Code) and type:
gcc --version
If it shows the version, MinGW is installed correctly.
If it says 'gcc' is not recognized, the PATH is not set.
- Add MinGW to Environment Variables
Press Win + S → search Environment Variables → “Edit the system environment variables”.
Click Environment Variables → under System Variables, find Path → Edit.
Add the path to your MinGW bin folder, e.g.:
C:\MinGW\bin
Click OK and restart VS Code.
- Check Your VS Code Terminal
In VS Code terminal, type:
gcc --version
If it now shows the version, you’re ready to compile.
- Compile Your C Code
In the terminal, run:
gcc Hello.c -o Hello.exe
.\Hello.exe
Avoid using ; if ($?) { ... } unless you know PowerShell scripting.
If you’re using PowerShell, just compile and run separately:
gcc Hello.c -o Hello .\Hello
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.hth
Marcin