Reputation: 111
I am having difficulty compiling a C program using the OpenGL and GLUT frameworks on Mac OSX. I am just getting started and I attempted to run code from this tutorial, on how to install OpenGL. http://www.prinmath.com/csci5229/misc/install.html.
Here is the code:
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
int main(){
return 0;
}
I am trying to compile it with:
gcc -o foo foo.c -framework GLUT -framework OpenGL
I am receiving this error:
foo.c:2:23: error: GLUT/glut.h: No such file or directory
After doing some further research here, http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/, I looked in /System/Library/Frameworks/ and both OpenGL.framework, and GLUT.framework where present.
Any help is greatly appreciated! Thank you!
Upvotes: 8
Views: 12974
Reputation: 42283
On Catalina (10.15.7), XCode 12.4 (12D4e) here's what worked for me :
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
...
Then compile with
gcc code.c -framework GLUT -framework OpenGL
Upvotes: 3
Reputation: 6623
Without installing glutg3-dev you can use OS X GLUT and OpenGL frameworks as follows
gcc -o foo foo.c -L/System/Library/Frameworks -framework GLUT -framework OpenGL
notice that it is important to tell the compiler the path to the frameworks
Upvotes: 5
Reputation: 6606
You need to install OpenGL Utility Toolkit glutg3-dev
lib.If it is already there then compile with -lglut -lGLU -lGL
option.
Upvotes: 3