安装 Mesa 来替换 GLUT 但出现编译错误

发布于 2024-12-12 03:26:15 字数 1038 浏览 0 评论 0原文

我正在尝试从红皮书中运行 hello.c在 MAC OS X Lion 上。我尝试通过“sudo port install glut”安装 GLUT,但收到消息:错误: glut 已被 mesa 取代;请安装 mesa。

所以,我安装了 mesa。但是,我仍然无法编译我的 hello.c。我使用以下命令进行编译:

gcc -lglut hello.c

但收到错误消息:

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)

基本上它在抱怨找不到 GL/glut.h。 Mesa不包含相同的头文件吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

横笛休吹塞上声 2024-12-19 03:26:15

glut 与 mesa 根本不一样,我不知道为什么 macport 这样做...

好消息是你可能不需要安装任何东西:

尝试:(将在 10.6 或 10.7 上工作,你可以其他版本必须调整sdk)

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 

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 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文