Search code examples
macosglutmesa

Installed Mesa to replace GLUT but got compilation error


I'm trying to run hello.c from the red book on MAC OS X Lion. I tried to install GLUT by "sudo port install glut" but got the message: Error: glut has been replaced by mesa; please install mesa instead.

So, I installed mesa instead. However, I still can't get my hello.c compiled. I used the following command to compile:

gcc -lglut hello.c

But got the error message:

hello.c:47:21: error: GL/glut.h: No such file or directory
hello.c: In function ‘display’:
hello.c:53: error: ‘GL_COLOR_BUFFER_BIT’ undeclared (first use in this function)
hello.c:53: error: (Each undeclared identifier is reported only once
hello.c:53: error: for each function it appears in.)
hello.c:59: error: ‘GL_POLYGON’ undeclared (first use in this function)
hello.c: In function ‘init’:
hello.c:78: error: ‘GL_PROJECTION’ undeclared (first use in this function)
hello.c: In function ‘main’:
hello.c:93: error: ‘GLUT_SINGLE’ undeclared (first use in this function)
hello.c:93: error: ‘GLUT_RGB’ undeclared (first use in this function)

Basically it's complaining about can't finding GL/glut.h. Doesn't Mesa contain the same header file?


Solution

  • glut isn't the same as mesa at all, I don't know why macport has done this...

    Good news is that you probably don't need to install anything:

    try:(will work on 10.6 or 10.7, you may have to adjust the sdk for other versions)

    gcc -I/Developer/SDKs/MacOSX10.6.sdk/usr/X11/include  -L/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib/ -lglut -lGLU -lGL -lXmu -lX11 hello.c