I downloaded and installed MinGW under C:\MinGw
and installed g and gcc.
If I run g --version
I get:
g .exe (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
If I run gcc --version
, I get:
gcc (GCC) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying
conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE
I'm trying to run a simple helloworld.cpp file from VSCode:
#include<iostream>
int main()
{
std::cout << "Hello World" << std::endl;
}
I've edited the c_cpp_properties.json file as follows:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\MinGW\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\g .exe",
"cStandard": "c17",
"cppStandard": "c 17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
But when I go and build/run the file, I get the following:
Starting build...
C:\cygwin64\bin\cpp.exe -fdiagnostics-color=always -g C:\Users\Pippo\Desktop\Programming\CPP\helloworld.cpp -o C:\Users\Pippo\Desktop\Programming\CPP\helloworld.exe
cpp: fatal error: cannot execute 'cc1plus': spawn: No such file or directory
compilation terminated.
Build finished with error(s).
Why is this failing? And why am I seeing Cygwin being called??
EDIT (more stuff I don't get):
The behaviour I showed before happens when I click on Run C/C File
But when I click on Run Code it works (and it calls g ):
EDIT (@Yakk - Adam Nevraumont answer): Nope, Cygwin is after g in my env vars:
CodePudding user response:
VSCode uses a completely separate tool chain for compiling and for linting and syntax highlighting and similar.
c_cpp_properties.json
isn't for compiling.
It gets the compiler typically from your PATH
. See here.
Your build task is probably set to the compiler g , and the first one on the search path (the PATH environment variable) is Cygwin's g .