0

I have just started learning C++ in Visual Studio code but for some reason, it is showing error but when I tried the same program on Devc++ I was able to get the desired output.

MY PROGRAM my program

#include<iostream>

using namespace std;

int main() 

{
    
cout<<"Hello world";
    
return 0;

}

This is the error that is flashing in the output:

ERROR:error error contd

[Running] cd "c:\Users\Swastik\Documents\c++" && g++ helloworld.cpp -o helloworld && "c:\Users\Swastik\Documents\c++"helloworld C:/Program Files/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain' collect2.exe: error: ld returned 1 exit status

[Done] exited with code=1 in 3.226 seconds

大陸北方網友
  • 3,696
  • 3
  • 12
  • 37
Ramsay
  • 3
  • 1
  • Your project is configured to build a Windows application, not a Console application. – paddy Oct 12 '20 at 05:40
  • @paddy, [This answer](https://stackoverflow.com/questions/5259714/undefined-reference-to-winmain16/5260237#5260237) suggests that GCC should work with `main` regardless of subsystem and without any particular compiler/linker flags. – chris Oct 12 '20 at 05:43

0 Answers0