• Advertisement
Sign in to follow this  

Problem compile/use freeglut

This topic is 4429 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Consider I'm a newbie in C++, so maybe it's only a my stupid error. I use DevC++ 4.9.9.2 under win XP. Actually I've classic GLUT installed and all glut examples work fine. I've imported the VC++ project, loading the freeglut_static.dsp into DevC++ (DevC++ has this useful import feature). I compile the static lib without problems. Here is the log, using -Wall option: ------------------------------------------------------------------------ src/freeglut_init.c:94: warning: unused parameter 'displayName' src/freeglut_init.c: In function `glutInitDisplayString': src/freeglut_init.c:718: warning: comparison between signed and unsigned src/freeglut_misc.c:146: warning: unused parameter 'nColor' src/freeglut_misc.c:146: warning: unused parameter 'red' src/freeglut_misc.c:146: warning: unused parameter 'green' src/freeglut_misc.c:146: warning: unused parameter 'blue' src/freeglut_misc.c:155: warning: unused parameter 'color' src/freeglut_misc.c:155: warning: unused parameter 'component' src/freeglut_misc.c:165: warning: unused parameter 'window' src/freeglut_overlay.c:39: warning: unused parameter 'layer' src/freeglut_overlay.c:41: warning: unused parameter 'ID' src/freeglut_state.c: In function `glutGetModifiers': src/freeglut_state.c:575: warning: comparison between signed and unsigned src/freeglut_videoresize.c:37: warning: unused parameter 'eWhat' src/freeglut_videoresize.c:40: warning: unused parameter 'x' src/freeglut_videoresize.c:40: warning: unused parameter 'y' src/freeglut_videoresize.c:40: warning: unused parameter 'w' src/freeglut_videoresize.c:40: warning: unused parameter 'h' src/freeglut_videoresize.c:41: warning: unused parameter 'x' src/freeglut_videoresize.c:41: warning: unused parameter 'y' src/freeglut_videoresize.c:41: warning: unused parameter 'w' src/freeglut_videoresize.c:41: warning: unused parameter 'h' ar r freeglut_static.a src/freeglut_callbacks.o src/freeglut_cursor.o src/freeglut_display.o src/freeglut_ext.o src/freeglut_font.o src/freeglut_font_data.o src/freeglut_gamemode.o src/freeglut_geometry.o src/freeglut_glutfont_definitions.o src/freeglut_init.o src/freeglut_joystick.o src/freeglut_main.o src/freeglut_menu.o src/freeglut_misc.o src/freeglut_overlay.o src/freeglut_state.o src/freeglut_stroke_mono_roman.o src/freeglut_stroke_roman.o src/freeglut_structure.o src/freeglut_teapot.o src/freeglut_videoresize.o src/freeglut_window.o ar: creating freeglut_static.a ranlib freeglut_static.a Execution terminated ------------------------------------------------------------------- I've renamed freeglut_static.a in libfreeglut.a and copied into default lib directory. After, I've copied all freeglut headers in default GL folder, overwriting the old files. Last, I've modified my compiler linker options, from -lopengl32 -lglu32 -lglut32 to -lopengl32 -lglu32 -lfreeglut So, I've tried to build a basic example: ----------------------------------------------------- #include <GL/glut.h> GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0}; /* Red diffuse light. */ GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0}; /* Infinite light location. */ GLfloat n[6][3] = { /* Normals for the 6 faces of a cube. */ {-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0} }; GLint faces[6][4] = { /* Vertex indices for the 6 faces of a cube. */ {0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4}, {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3} }; GLfloat v[8][3]; /* Will be filled in with X,Y,Z vertexes. */ void drawBox(void) { int i; for (i = 0; i < 6; i++) { glBegin(GL_QUADS); glNormal3fv(&n[0]); glVertex3fv(&v[faces[0]][0]); glVertex3fv(&v[faces[1]][0]); glVertex3fv(&v[faces[2]][0]); glVertex3fv(&v[faces[3]][0]); glEnd(); } } void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); drawBox(); glutSwapBuffers(); } void init(void) { /* Setup cube vertex data. */ v[0][0] = v[1][0] = v[2][0] = v[3][0] = -1; v[4][0] = v[5][0] = v[6][0] = v[7][0] = 1; v[0][1] = v[1][1] = v[4][1] = v[5][1] = -1; v[2][1] = v[3][1] = v[6][1] = v[7][1] = 1; v[0][2] = v[3][2] = v[4][2] = v[7][2] = 1; v[1][2] = v[2][2] = v[5][2] = v[6][2] = -1; /* Enable a single OpenGL light. */ glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); /* Use depth buffering for hidden surface elimination. */ glEnable(GL_DEPTH_TEST); /* Setup the view of the cube. */ glMatrixMode(GL_PROJECTION); gluPerspective( /* field of view in degree */ 40.0, /* aspect ratio */ 1.0, /* Z near */ 1.0, /* Z far */ 10.0); glMatrixMode(GL_MODELVIEW); gluLookAt(0.0, 0.0, 5.0, /* eye is at (0,0,5) */ 0.0, 0.0, 0.0, /* center is at (0,0,0) */ 0.0, 1.0, 0.); /* up is in positive Y direction */ /* Adjust cube position to be asthetic angle. */ glTranslatef(0.0, 0.0, -1.0); glRotatef(60, 1.0, 0.0, 0.0); glRotatef(-20, 0.0, 0.0, 1.0); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("red 3D lighted cube"); glutDisplayFunc(display); init(); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ } ------------------------------------------------------- But it don't work: g++.exe prova_freeglut.o -o "prova_freeglut.exe" -L"C:/Dev-Cpp/lib" -lopengl32 -lglu32 -lfreeglut prova_freeglut.o(.text+0x103):prova_freeglut.cpp: undefined reference to `_imp__glutSwapBuffers@0' prova_freeglut.o(.text+0x34c):prova_freeglut.cpp: undefined reference to `_imp__glutInit@8' prova_freeglut.o(.text+0x35d):prova_freeglut.cpp: undefined reference to `_imp__glutInitDisplayMode@4' prova_freeglut.o(.text+0x36e):prova_freeglut.cpp: undefined reference to `_imp__glutCreateWindow@4' prova_freeglut.o(.text+0x37f):prova_freeglut.cpp: undefined reference to `_imp__glutDisplayFunc@4' prova_freeglut.o(.text+0x38e):prova_freeglut.cpp: undefined reference to `_imp__glutMainLoop@0' collect2: ld returned 1 exit status make.exe: *** [prova_freeglut.exe] Error 1 Execution terminated -------------------------------------------------------- Help!!!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement