My openGL program wont link!

I was trying to run a code example from the book i’m trying to learn openGL from, and it won’t work (VERY disappointed ) I’m using VC++ 6.0.

Please help me, i really want to learn!

CODE (from openGL programming guide third edition):

#include “GL/glut.h”

void display(void)
glColor3f(1.0, 1.0, 1.0);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.25, 0.25, 0.0);



void init(void)
glClearColor(0.0, 0.0, 0.0, 0.0);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);

int main(int argc, char* argv[])
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
return 0;


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

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

Looks like you started the project as a Win32 Application. Start it as a Win32 console instead.

Ive tried that already… Nothing works…

my problem is quite similar…i cant figure it out either

Well, I don’t use glut so I’m not sure if it matters whether or not your using a win32 or console application but my guess would be win32 is fine. In any case try doing this.


  1. Go to ‘Project’->‘Settings’.
  2. Locate te ‘Link’ tab.
  3. In the ‘Category’ combo box choose ‘Input’. (It’s probably set to ‘General’ right now.)
  4. Now in the edit box for ‘Ignore libraries’ type this…
  5. That should take care of the problem I believe, then again I never have used glut so I don’t know how its window creation code works.

Good Luck,

are you linking with the windows lib (like winmm.lib) and did you include the “windows.h” file ??

add this 3 lines under #include<GL/glut.h>

#pragma comment(lib, “opengl32.lib”)
#pragma comment(lib, “glu32.lib”)
#pragma comment(lib, “glut32.lib”)

Thanks all! I’ll try it!

The problem is that your program is looking for a WinMain() function for the entry point instead of main(). Since you didn’t implement that, it can’t find it, thus you get a linker error. A win32 Application differs from a Win32 console in that the application sets the entry point as WinMain() and console uses the entry point as main().

If you tried it by starting the project as a Win32 Console, you shouldn’t have gotten the same error.

heh, still a little used to VB, are we?