0

I am new to visual studio code & I am trying to configure it with C++. I have installed MinGW compiler and It is successfully installed (I tested it with a command g++ --version on a command prompt). I have also added the environment path in the system settings. I have also installed Code runner extension in VS code, but when I try to compile my code, I get this error:

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../libmingw32.a(main.o):(.text.startup+0xb0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status

I searched about this problem for a while but I am still unable to fix this issue. I have learned while searching that I am getting this error because I am not using the main function but I am just trying to compile simple hello world code.

#include<iostream>
using namespace std;
int main()
{
 cout<<"Hello world";
}
Xacer
  • 21
  • 3
  • It looks like you're targeting the windows instead of console subsystem. There should be a setting for that. – rustyx Aug 01 '19 at 11:07
  • 2
    Possible duplicate of [undefined reference to \`WinMain@16'](https://stackoverflow.com/questions/5259714/undefined-reference-to-winmain16) – 500 - Internal Server Error Aug 01 '19 at 11:09
  • I used visual studio once and there was an option to choose console, windows & other application projects but in Visual studio code, I am unable to find any settings related to this. – Xacer Aug 01 '19 at 11:10

0 Answers0