【问题标题】:compiling OpenGL program in cygwin fails在 cygwin 中编译 OpenGL 程序失败
【发布时间】:2020-12-02 21:10:09
【问题描述】:

我正在尝试编译一个 opengl C 程序。我在 Windows 平台上,我使用 cygwin。该程序使用以下命令编译。

gcc -o parallel test.c -std=c99 -lglut -lGL -lm

我的 cygwin 中安装了以下软件包。

但是当我尝试编译应用程序时,我收到以下错误。

$ gcc -o parallel test.c -std=c99 -lglut -lGL -lm
In file included from /usr/include/GL/freeglut_std.h:144,
                 from /usr/include/GL/glut.h:17,
                 from test.c:37:
/usr/include/w32api/GL/glu.h:68:78: error: expected ‘)’ before ‘*’ token
   68 | void APIENTRY gluQuadricCallback(GLUquadric *qobj,GLenum which,void (CALLBACK *fn)());
      |                                                                              ^~
      |                                                                              )
/usr/include/w32api/GL/glu.h:78:78: error: expected ‘)’ before ‘*’ token
   78 | void APIENTRY gluTessCallback(GLUtesselator *tess,GLenum which,void (CALLBACK *fn)());
      |                                                                              ^~
      |                                                                              )
/usr/include/w32api/GL/glu.h:94:74: error: expected ‘)’ before ‘*’ token
   94 | void APIENTRY gluNurbsCallback(GLUnurbs *nobj,GLenum which,void (CALLBACK *fn)());
      |                                                                          ^~
      |                                                                          )
/usr/include/w32api/GL/glu.h:96:23: error: expected ‘)’ before ‘*’ token
   96 | typedef void (CALLBACK *GLUquadricErrorProc)(GLenum);

在此之前我有另一个错误,那就是

$ gcc -o parallel test.c -std=c99 -lglut -lGL -lm
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status

我试图通过安装libGL-devel 来解决这个问题,但这导致了第一个错误。我一直在寻找可能的解决方案,但其中大多数都已过时。

这是我们给出的代码中包含部分的样子。

#ifdef _WIN32
#include <windows.h>
#endif
#include <stdio.h> // printf
#include <math.h> // INFINITY
#include <stdlib.h>
#include <string.h>

// Window handling includes
#ifndef __APPLE__
#include <GL/gl.h>
#include <GL/glut.h>
#else
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#endif

【问题讨论】:

  • 看来您使用的是 /usr/include/w32api 内的 include 而不是 /usr/include/GL 内的一个。这很奇怪。

标签: opengl cygwin


【解决方案1】:

安装libGLU-devel

$ cygcheck -f /usr/include/GL/glu.h

libGLU-devel-9.0.1-1

编译器正在使用而不是

/usr/include/w32api/GL/glu.h 所属

$ cygcheck -f /usr/include/w32api/GL/glu.h

w32api-headers-8.0.0-1

因为包含搜索顺序是

$ gcc -xc -E -v  -
...
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-cygwin/10/include
 /usr/local/include
 /usr/include
 /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../lib/../include/w32api
End of search list.

最后一个是usr/include/w32api

【讨论】:

    猜你喜欢
    • 2012-03-30
    • 1970-01-01
    • 2021-01-29
    • 1970-01-01
    • 2015-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-14
    相关资源
    最近更新 更多