undefined ref to glutLeaveMainLoop

Hi all,
I have a big problem (well, for me, it’s big, but I am sure it’s nothing for you!).

I am using freeglut, and the magic glutLeaveMainLoop function.

Freeglut is installed and working. I have no problem using freeglut, except when I try to glutLeaveMainLoop. It says ‘undefined reference to ‘glutLeaveMainLoop’’. I have been trying for hours to figure out why, but I can’t!

I have tried replacing freeglut by openglut (no, I didn’t forget to change the includes!), and nothing!

I would be very grateful if someone can help me!!!

Here is my code:


#include <GL/freeglut_std.h>
#include <GL/freeglut_ext.h>
#include <stdlib.h>

void quad()
                glVertex2f( 0.0f, 1.0f);  // Top Left
                glVertex2f( 1.0f, 1.0f);  // Top Right
                glVertex2f( 1.0f, 0.0f);  // Bottom Right
                glVertex2f( 0.0f, 0.0f);  // Bottom Left

void draw()
        // Make background colour black
        glClearColor( 0, 0, 0, 0 );
        glClear ( GL_COLOR_BUFFER_BIT );
        // Push the matrix stack - more on this later

        // Set drawing colour to blue
        glColor3f( 0, 0, 1 );
        // Move the shape to middle of the window
        // More on this later
        glTranslatef(-0.5, -0.5, 0.0);
        // Call our Quad Method

        // Pop the Matrix
        // display it 

// Keyboard method to allow ESC key to quit
void keyboard(unsigned char key,int x,int y)

int main(int argc, char **argv)
        // Double Buffered RGB display 
        glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);
        // Set window size
        glutInitWindowSize( 500,500 );
        // Declare the display and keyboard functions
        // Start the Main Loop


I’ve never seen that function before, cool!

A little searching reveals that older versions of GLUT, even free and open did not support this.

Since you don’t do anything after you leave the main loop, you might consider just calling exit().