Compiling OpenGL and GLUT OSX

六月ゝ 毕业季﹏ 提交于 2020-08-27 07:12:58

问题


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!


回答1:


You need to install OpenGL Utility Toolkit glutg3-dev lib.If it is already there then compile with -lglut -lGLU -lGL option.




回答2:


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



来源:https://stackoverflow.com/questions/18372651/compiling-opengl-and-glut-osx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!