PDA

View Full Version : VC++ Compiler Problem!!!



05-30-2004, 07:10 PM
I'm a beginner.I write a program:

#include <windows.h>
#include <GL\gl.h>
#include <GL\glaux.h>

int main(void)
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,500,500);
auxInitWindow("simple");

glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);

glColor3f(1.0,0.0,0.0);
glRectf(-0.5,-0.5,0.5,0.5);

glFlush();
return 1;
}

When I compiler the program,passed!!But,when I run the program,error occured:

--------------------Configuration: simple - Win32 Debug--------------------
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/simple.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

simple.exe - 2 error(s), 0 warning(s)

What I can do???

mikael_aronsson
05-30-2004, 10:05 PM
Hi !

You have told the linker to create a GUI application, and that is why it is looking for a WinMain function, if you want to create a console application (that is when you have a main() function) you need to tell the linker this, if you are using Visual Studio there is a settings for this in the linker properties, if you are using the linker from the console yoiu mus specify an option for this, don't remember which one at the moment.

If you search on "WinMain" in this forum you will find more information.

Mikael

yzw999
05-31-2004, 04:07 PM
Thanks!
I have run this program successedly!
Method No.1:
Change the function main() to WinMain().
Method No.2:
To Build a Console Application.

Finally,Thanks to Mikael.