Click here to Skip to main content
15,907,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i run this

#include <iostream>

int main(){
cout << "hello world" << endl;
return 0;
}


i get this error

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

[Done] exited with code=1 in 0.83 seconds


What I have tried:

i tried reinstalling everything but it dint work
Posted
Updated 20-May-21 1:00am

WinMain is the entry point for a windows process. main is the entry point for a console process. You need to target a console process with your compiler.
 
Share this answer
 
Comments
Member 13962174 26-Aug-18 22:34pm    
And how do i do that?
Rick York 27-Aug-18 12:28pm    
In VS17 go to the project's Configuration Properties->Linker->System->SubSystem and select Console.
KarstenK 27-Aug-18 3:59am    
Easiest is to start a new project with the project wizard and choose the console type of app.
Member 13962174 27-Aug-18 6:11am    
Starting a new project in visual studio code did not work
Simple. Just save your code and then run it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900