将openGL,GLU和GLUT库链接到Visual C ++

时间:2013-07-20 17:58:48

标签: visual-studio-2010 visual-c++ opengl glut glu

完全遵循这里提到的步骤,我得到了243个错误?! 发生了什么?

Error   1   error C2144: syntax error : 'void' should be preceded by ';'    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152    Win32OpenGL 1
Error   2   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152    Win32OpenGL 1
Error   3   error C2146: syntax error : missing ';' before identifier 'glAccum' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152    Win32OpenGL 1
Error   4   error C2182: 'APIENTRY' : illegal use of type 'void'    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152    Win32OpenGL 1
Error   5   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152    Win32OpenGL 1
Error   6   error C2144: syntax error : 'void' should be preceded by ';'    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153    Win32OpenGL 1
Error   7   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153    Win32OpenGL 1
Error   8   error C2086: 'int WINGDIAPI' : redefinition c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153    Win32OpenGL 1
Error   9   error C2146: syntax error : missing ';' before identifier 'glAlphaFunc' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153    Win32OpenGL 1
Error   10  error C2182: 'APIENTRY' : illegal use of type 'void'    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153    Win32OpenGL 1
Error   11  error C2086: 'int APIENTRY' : redefinition  c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153    Win32OpenGL 1
Error   12  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153    Win32OpenGL 1
Error   13  error C2146: syntax error : missing ';' before identifier 'GLboolean'   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154    Win32OpenGL 1
Error   14  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154    Win32OpenGL 1
Error   15  error C2086: 'int WINGDIAPI' : redefinition c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154    Win32OpenGL 1
Error   16  error C2146: syntax error : missing ';' before identifier 'glAreTexturesResident'   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154    Win32OpenGL 1
Error   17  error C2371: 'APIENTRY' : redefinition; different basic types   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154    Win32OpenGL 1

等等。你看到gl.h中发生的所有错误都不是我实现的! 我创建了一个win32应用程序空项目,添加了一个源文件,我在.cpp文件中只有这些代码。

#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\glut.h>


int main()
{
    return 0;
} 

1 个答案:

答案 0 :(得分:0)

在此处查看类似问题:Sudden issues with glut and glew includes and type specifiers

另一个在这里:Getting many OpenGL Errors

我使用的应用程序:

#include "gl/glew.h"
#include "gl/wglew.h"
#include "freeglut.h"