I am trying for the first time to program in OpenGl using visual C++. I copied a program directly out of a book and it compiles fine, but doesnt link. It keeps giving me an error that says something like unreslolved external symbol _WinMain@16 What do I do to fix this?

You’re using main() and your compiler’s looking for WinMain(). You needed to create a Win32 Console Application when you initially made your project, instead of a Win32 Application.

…or is it the other way around? Oh well…

Ok, i fixed that, but now when i compile, the program will work, but there is a box in the backround that doesnt do anything. How do I get rid of this?


I guess if it’s actually supposed to do something, then it doesn’t work. Try posting the code you’re using, so we may see what you’re doing wrong…or are you referring to the console window?

Yeah, how do i get rid of it?

#include <GL/glut.h>
#include <stdlib.h>

void display(void)

glVertex3f(0.25, 0.25, 0.0);


void init(void)

int main(int argc, char** argv)
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
return 0;

<sarcastic voice>Actually, I never figured that one out lol</sarcastic voice>

There is another discussion that you might want to read. The person’s asking the exact same question you are.

I had a similiar problem when I just started out. You must remeber that when a 3D object is projected onto a viewing plane, the camera must not be at exactely the same position as the viewing plane or you will get division by zero errors for the perspective projections.
Thus opengl does not even bother drawing them. All you need to do is to move your camera back a bit before you actually start drawing.

glTranslatef(0.0, 0.0, -5.0); //move the object 5 units in the negative Z-Axis direction.

Hope this helps.

, but there is a box in the backround that doesnt do anything. How do I get rid of this?

this is a console window. when you create a Win32 Console Application, your executable is run from this console (just a DOS window). this is where any printf/cout statements will be displayed. with the console app, your program will need a main(). if you create a Win32 Application, there is no DOS window. this requires a WinMain(). as for making the DOS window go away, i seem to remember hearing about this. search this forum for “DOS window” or “console window”.


There’s a compiler setting you can add to not show the console box. It’s in the FAQ. You can also use the Win32 function FreeConsole. This method is, of course, specific to Windows.

What FAQ?

The one on OpenGL’s web site. This link’ll take you directly to the part on GLUT, however, what you’re requesting is towards the bottom of this page.

Basically, all it says is this:

3.100 How do I get rid of the console window in a Windows GLUT application?

With Visual C++ 6.0, go to the Project menu, Settings… dialog. Select the Link tab. In the Project options edit box, add /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup to the end of the present text. Link options are similar for other Windows compilers.

…dunno how to do this in Borland, though.