PDA

View Full Version : Why my code can not be compiled :(



Marco2005
02-26-2005, 11:14 PM
my code is at below:

/********************************************/
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <windows.h>

main()
{
InitializeAWindowPlease();

glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glFlush();
UpdateTheWindowAndCheckForEvents();
}
/***********************************************/

When I build that.. there would be 4 errors:

1.
test_one.obj : error LNK2001: unresolved external symbol _UpdateTheWindowAndCheckForEvents

2.
test_one.obj : error LNK2001: unresolved external symbol _InitializeAWindowPlease

3.
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

4.
Debug/test_one.exe : fatal error LNK1120: 3 unresolved externals

please help me...why such errors are there..... :(

Thanks! :confused:

MMMovania
02-27-2005, 01:43 AM
Originally posted by Marco2005:
my code is at below:

/********************************************/
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <windows.h>

main()
{
InitializeAWindowPlease();

glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glFlush();
UpdateTheWindowAndCheckForEvents();
}
/***********************************************/

When I build that.. there would be 4 errors:

1.
test_one.obj : error LNK2001: unresolved external symbol _UpdateTheWindowAndCheckForEvents

2.
test_one.obj : error LNK2001: unresolved external symbol _InitializeAWindowPlease

3.
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

4.
Debug/test_one.exe : fatal error LNK1120: 3 unresolved externals

please help me...why such errors are there..... :(

Thanks! :confused: Hello there,
You have taken this code from the opengl programming guide presumably. There is no such function in opengl as InitializeAWindowPlease(); or UpdateTheWindowAndCheckForEvents(); These functions are given here as place holders. Depending upon your OS, you have to do the opening and closing of windows and other os related stuff in plavce of these place holders. If you use glut, window handling will be dealt with by glut itself otherwise you would have to give WinMain handler yourself. Have a look at nehe's turoials at http://www.nehe.gamedev.net or Nate robins turotials at http://www.xmission.com/~nate/opengl for help on this. Check both glut and win32 stuff. thanx

Silkut
02-27-2005, 03:58 AM
Don't forget the programming guide, th is simply the best method to visualise how-to-render-a-thing/effect