【问题标题】:Installed Mesa to replace GLUT but got compilation error安装 Mesa 来替换 GLUT 但出现编译错误
【发布时间】:2011-10-24 21:15:08
【问题描述】:

我正在尝试从 MAC OS X Lion 的红皮书中运行 hello.c。我尝试通过“sudo port install glut”安装 GLUT,但收到消息:错误:过剩已被台面替换;请改为安装台面。

所以,我安装了 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不是包含同一个头文件吗?

【问题讨论】:

    标签: macos glut mesa


    【解决方案1】:

    glut 根本就和 mesa 不一样,我不知道 macport 为什么会这么做……

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

    try:(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 
    

    【讨论】:

    • 你可能不需要我刚刚从工作项目中偷偷复制的所有其他 -l 库
    • 但由于它们是动态链接的,它不会使您的程序膨胀。
    猜你喜欢
    • 1970-01-01
    • 2020-08-16
    • 2013-02-02
    • 1970-01-01
    • 1970-01-01
    • 2020-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多