0

Im installed mingw and vs code on my system , i followed all the steps,added to environment variable and all but when im running simple hello world program it gives this error: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status My code : #include<iostream using namespace std;

int main(){

cout<<"Hello World"<<endl;
return 0;

}

  • You have passed the wrong options to the compiler, specifically `-mwindows`. The error indicates that the compiler thinks you are trying to build a Windows GUI program, but your code indicates that you are trying to build a console program. Remove `-mwindows` from your command line. – john Jan 25 '21 at 07:52
  • Can you tell me how to do this in VS code – Aniket Tiwari Jan 25 '21 at 08:07
  • I'm not familiar with mingw in VSCode, but you need to edit the part of tasks.json where the mingw compiler options are. – john Jan 25 '21 at 08:10
  • If you can't figure it out then you should post tasks.json as part of the question. – john Jan 25 '21 at 08:14

0 Answers0