Skip to main content
GameDev.net gamedev.net
🔒 Locked

What The ?: Glut Linker Errors

Started by Leiarchy9 Jan 11, 2004 at 7:49 PM 8 replies 13.9k views
Original Post
Leiarchy9
Leiarchy9
[Linker error] undefined reference to `__glutInitWithExit@12'' 
[Linker error] undefined reference to `__glutCreateWindowWithExit@8'' 
[Linker error] undefined reference to `__glutCreateMenuWithExit@8''
I''m using Dev-C++ 4.9. I''m linking to: -lopengl32 -lglu32 -lglut32 What is wrong? -------- "Do you believe in Ghost?"
--------"Do you believe in Ghost?"
Leiarchy9
Leiarchy9
I''m not sure if this would help much but here is the source code. Just a simple window initiation. Nothing drawn or anything special.


#include <stdio.h>
#include <stdlib.h>

#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>



void InitOpenGL()
{

glEnable( GL_DEPTH_TEST );
glShadeModel( GL_SMOOTH );
}


void glutKeyboard( unsigned char key, int x, int y )
{

switch( key )
{

case 27:
exit( EXIT_SUCCESS );
break;
}

}


void glutResize( int width, int height )
{

if( height== 0 ) { height= 1; }

glViewport( 0, 0, width, height );

glMatrixMode( GL_PROJECTION );
glLoadIdentity();

gluPerspective( 45.0f, (GLfloat)(width/height), 1.0f, 150.0f );

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}


void glutDisplay(void)
{

glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClearDepth( 32 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );



glFlush();
glutSwapBuffers();
}



int main( int argc, char **argv )
{

glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA );

glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 640, 480 );
glutCreateWindow( "~~Glut Example~~" );

glutKeyboardFunc( glutKeyboard );
glutReshapeFunc( glutResize );
glutDisplayFunc( glutDisplay );

InitOpenGL();

glutMainLoop();

return EXIT_SUCCESS;
}


--------
"Do you believe in Ghost?"
--------"Do you believe in Ghost?"
aleks_1661
aleks_1661
ok the problem you are having is that the version of GLUT you have is an old version, the __glutCreateWindowWithExit function was not present in the earlier glut libraries. Get new ones.

Either that or you Lib and .h files for glut are different versions.

[edited by - aleks_1661 on January 12, 2004 8:08:01 AM]
Twitter: [twitter]CaffinePwrdAl[/twitter] Website: (Closed for maintainance and god knows what else)
paulc
paulc
I think you may need to add this line:


#define GLUT_DISABLE_ATEXIT_HACK

#include "gl/glut.h"


Make sure it is before the glut include as above.
I had similar problems using MinGW, which I believe Dev C++ is built around and this solved my link problems.
Leiarchy9
Leiarchy9
It compiles fine without any linker errors but I''m still having trouble with it. I can''t re-compile because permission is denied. The .exe I built also remains there and I can''t delete it because I get message that ''permission is denied''.

Did I do something wrong in the code?
Doesn''t GLUT have like a DeInit function to properly exit out of the video mode?

--------
"Do you believe in Ghost?"
--------"Do you believe in Ghost?"
smitty1276
smitty1276
When it gives you the "Permission denied" error, hit Ctl-Alt-Delete and see if it is still listed under the running processes. I''ve had that problem before and it turned out I was doing something wrong when closing down... the window was closed but execution hadn''t halted properly.
Fruny
Fruny
Using GLUT with MinGW32.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Leiarchy9
Leiarchy9
Alright, it turns out that it had three spots in the processes list. How do I properly shut down glut though(coding wise)?

--------
"Do you believe in Ghost?"
--------"Do you believe in Ghost?"
Fruny
Fruny
quote:
Original post by Leiarchy9
Alright, it turns out that it had three spots in the processes list. How do I properly shut down glut though(coding wise)?


You don''t. glutMainLoop() never returns. You can modify the code (as I have done) so that it does.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Leiarchy9
Leiarchy9
Actually, I just added this piece of code and my application exits fine.


int main( int argc, char **argv )
{

glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA );

glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 640, 480 );
int Window_ID= glutCreateWindow( "~~Glut Example~~" );

glutKeyboardFunc( glutKeyboard );
glutReshapeFunc( glutResize );
glutDisplayFunc( glutDisplay );

InitOpenGL();

glutMainLoop();
glutDestroyWindow( Window_ID );

return EXIT_SUCCESS;
}
--------"Do you believe in Ghost?"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.