I'm trying to run a simple Hello World C program in VSCode, on Windows 10, to test whether things are going fine or not (I previously had to reinstall the OS). So this is the code:
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
Should be simple, and it should run perfectly well, I thought. I tried it with these options, which I assume was from the Code Runner
(by Jun Han) extension. When I try selecting the "Run Code" option, everything works well, and the code runs perfectly. When I tried the "Debug C/C File" or the "Run C/C File" option, however, this was what I got.
* Executing task: C/C : gcc.exe build active file
Starting build...
C:\Compilers\MinGW\bin\gcc.exe -fdiagnostics-color=always -g D:\Alfred\Studies\College\Skripsi\resources\preparations\CTest\HelloWorld.c -o D:\Alfred\Studies\College\Skripsi\resources\preparations\CTest\HelloWorld.exe
The system cannot find the path specified.
Build finished with error(s).
* The terminal process failed to launch (exit code: -1).
* Terminal will be reused by tasks, press any key to close it.
Worth noting here that C:\Compilers\MinGW\bin\gcc.exe
is my MinGW directory in the system path before I reinstalled the OS. I'm not sure why it pulls that specific path, considering:
- I've tested the MinGW installation on the reinstalled OS, and running the
gcc --version
command works on cmd, - The system environment variable has been set to the new path (
C:/MinGW/bin
), - If it's really a problem with MinGW paths, logically the "Run Code" option should also fail. Yet it doesn't.
- Finally, I've also tried restarting the laptop, reinstalling MinGW, reinstalling VSCode (along with deleting the
.vscode
folder in %USERPROFILE% andCode
folder in %APPDATA%), but this problem still persists.
I've been looking for the possibility as to why for hours now, yet I haven't managed to. Was hoping some of you could tell me what I overlooked here.
P.S.:
- The only extensions I have installed are
C/C
by Microsoft andCode Runner
by Jun Han. - Please bear with me if my question was missing some details - I have very little experience in asking questions here.
Edit 1: I've been told this was due to Microsoft's C/C
extension, and not Jun Han's Code Runner
. I have edited the title to reflect so.
CodePudding user response:
The two options you mentioned are from the Microsoft's C/C extension: they use the C_Cpp.default.compilerPath
setting to locate your compiler. You can change it either the settings GUI or in the JSON file.