I tried starting using C++ on VSCode (I am currently on Windows 11), but after having installed mingw-w64, and using the g++ command line, it seems that the compiler does not work, i.e. I receive a cc1plus.exe Application error.
I followed the following steps:
1/ Install g++ compiler through https://www.msys2.org/, and simply followed the instruction (pacman -S mingw-w64-ucrt-x86_64-gcc, and pacman -Suy). g++ is rightly understood by Windows: g++ on cmd
2/ Added the mingw64 to the environment variables as you can see below: windows environment variables
3/ Installed C/C++ extension on VSCode, C/C++ Compile Run extension and wrote a very simple Hello World program:
#include <iostream>
main()
{
std::cout << "Hello, World!\n";
return 0;
}
4/ Using Comile & Run returns an error: Compile&run error
5/ Just in case, I tried to run the compile on windows cmd (where I know g++ is understood):
(the file source is in D:/Code/c++/test.exe), using the following command:
g++ -o test.exe test.cpp
(where cmd is in D:/Code/c++)
This returns a cc1plus.exe - Application error message
I spent an entire day trying to figure out what is going wrong. The issue is before the linkage nor in the assembler as g++ -S test.exe
returns the same error.
Did anyone experienced the same issue? Would love to have some guidance here (PS: tried on Visual Studio as well, and it is not working neither, so it might be in the system settings, but I have no knowledge on the topic at all).
EDIT: Removed the using namespace std;
as suggested, but this did not solve the issue.