# Eclipse problem: undefined reference to WinMain@16'

This topic is 2518 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

First I download Eclipse for C++. I then download and install MinGW. After that I create a C++ project that is using the MinGW tool chain and add a cpp file to it. Finally I type this into the cpp file:

#include<"windows.h">

int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
return 0;
}

Then I try to build it but I get this error:

C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to WinMain@16'[/quote]

I think this means that it can't find the winmian function but I clearly defined it. Any idea what the problem is?

##### Share on other sites
Did you set UNICODE as a define in your compiler settings, by any chance?

##### Share on other sites

Did you set UNICODE as a define in your compiler settings, by any chance?

Not that I'm aware of. I literally did the exact steps which I gave. Nothing more and nothing less. I also tried it on a computer at school and had the same issue. I'm sure if you were to repeat those step you would get the same error.

##### Share on other sites
Your #include of windows.h looks suspicious - angle brackets as well as quotes. You should only use angle brackets.

##### Share on other sites

Your #include of windows.h looks suspicious - angle brackets as well as quotes. You should only use angle brackets.

No, that was just a mistake in my syntax while writing this post. However, I was able to get it to compile but it appears to be a bug in eclipse. I have to go in to the run configurations and double click C/C++ Application to create a new run configuration. After that I have to first attempt to run it and it will give me an error but then after I can build it. I then have to manually set the exe file I built and when I try to run it again everything works as it is suppose to. It does not make any sense to me. Is this a bug or am I misunderstanding something?

1. 1
2. 2
Rutin
19
3. 3
khawk
19
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633771
• Total Posts
3013762
×