PDA

View Full Version : GLUT link error



BASIC
08-05-2002, 05:06 PM
When I compile an OpenGL program using GLUT, I get the errors:

c:\dev-c++\opengl examples\opengl_main.o(.text+0x17) opengl_main.c: undefined reference to `__glutInitWithExit@12'
c:\dev-c++\opengl examples\opengl_main.o(.text+0x3b) opengl_main.c: undefined reference to `__glutCreateWindowWithExit@8'
c:\dev-c++\opengl examples\opengl_main.o(.text+0x67) opengl_main.c: undefined reference to `__glutCreateMenuWithExit@8'

--------------------------------------
This is my code:

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

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);

glColor3f(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();
}

void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{

glutInit(0, 0);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("hello");
init();
glutDisplayFunc(display);
glutMainLoop();

}

Can anyone help me?
Thanks


[This message has been edited by BASIC (edited 08-05-2002).]

[This message has been edited by BASIC (edited 08-05-2002).]

LoWang
12-17-2003, 07:46 AM
This solved my problem
http://www.opengl.org/discussion_boards/ubb/Forum10/HTML/000134.html

Z
12-17-2003, 02:49 PM
wheres your wndproc?