【发布时间】: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内的一个。这很奇怪。