• Advertisement

Archived

This topic is now archived and is closed to further replies.

What The ?: Glut Linker Errors

This topic is 5155 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

[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?"

Share this post


Link to post
Share on other sites
Advertisement
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?"

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?"

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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?"

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites

  • Advertisement