Cannot configure OpenGL / GLUT

Hi, I'm trying to get a simple program to run on my iBookG4, i've configured the makefile and .cpp file (included below) but it keeps coming up with the following error message when i type 'make hello':
/usr/bin/ld: Undefined symbols:
_glClear
_glClearColor
_glColor3f
_glFlush
_glutCreateWindow
_glutMainLoop
collect2: ld returned 1 exit status
make: * [hello] Error 1

I got a friend of mine with a mac to run it on theirs and it works fine, but for some reason it just wont compile on mine, i have both OpenGL and GLUT frameworks installed (as came with the computer).
I don't know what else to try, any help would be great.

--------MAKEFILE-------
CC = g++ -g -Wall -ansi

all:

${CC} *.cpp -framework OpenGL -framework GLUT -o output.exe

clean:
rm *.exe

--------HELLO.CPP---------- Just so you know what it is trying to access:

#include <stdio.h>

#include <OpenGL/gl.h>

#include <GLUT/glut.h>



void display(void)

{

glClear(GL COLOR_BUFFERBIT);

glFlush();

}



void init()

{



/* set clear color to black */



glClearColor (0.1, 0.0, 0.5, 0.0);

/* set fill color to white */



glColor3f(1.0, 0.0, 0.0);



/* set up standard orthogonal view with clipping */

/* box as cube of side 2 centered at origin */

/* This is default view and these statement could be removed */



/* glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); */

}

int main(int argc, char** argv)

{



/* Initialize mode and open a window in upper left corner of screen */

/* Window title is name of program (arg[0]) */



/* glutInit(&argc,argv); */

// glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); /

// glutInitWindowSize(600,600);

// glutInitWindowPosition(300,200);

glutCreateWindow("Function = sinc(x)");

// glutDisplayFunc(display);

// init();

glutMainLoop();



}

----------

Thanks,
Dan

iBook G4, Mac OS X (10.4.4)

Posted on Feb 15, 2006 9:03 AM

Reply
2 replies

Feb 15, 2006 4:22 PM in response to danic85

Hi Dan,
It looks rather like you're mixing some windoze stuff into this. The "output.exe" looks particularly ominous but all of the empty lines in the posted source code causes me to think that the original had DOS line endings. The first thing I would do is to make sure the file has UNIX line endings. Once I did that, I was able to compile the code simply with:

c++ -framework OpenGL -framework GLUT -o hello hello.cpp

Of course this assumes that hello.cpp is in your current working directory. However, you've commented out too many lines for the executable to run. In particular, you must have the following line in the code for it to run:

glutInit(&argc,argv);

After I uncommented that line, the executable executed without error. Of course it doesn't show anything, causing me to believe that more is missing, but the window opens.
--
Gary
~~~~
Cogito cogito ergo cogito sum --
"I think that I think, therefore I think that I am."
-- Ambrose Bierce, "The Devil's Dictionary"

Feb 15, 2006 8:59 PM in response to danic85

Hi Dan,

Your Makefile has no rule for 'hello', but you run the make command as 'make hello'. So the make command uses the built-in implicit rule to create 'hello' from 'hello.cpp'. When you run 'make hello', you see the actual command invoked by make, which may be something like

g++ -g -Wall -ansi hello.cpp -o hello

This has no reference to OpenGL/GLUT frameworks and the link fails, of course.

Just try 'make', or 'make all'.
As Gary says, the Makefile sets the output executable file name to 'output.exe', which is a bad name in MacOSX. Modify it as you like (for example just 'hello').

PowerMac G4 Mac OS X (10.4.3)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Cannot configure OpenGL / GLUT

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.