我正在尝试编写一个我通过MinGW编译的OpenGL程序。我成功地将OpenGL,GLUT,GLFW和GLM链接到我的main.cpp文件。给出以下标题:
#include "GL/glut.h"
#include "GLFW/glfw3.h"
#include "GL/glew.h"
#include "glm/vec3.hpp"
以下cmd行:
g++ -o leaf.exe -Wall physics.cpp -mwindows lib/glut32.lib -lopengl32 -lglu32 -lglfw3dll -lglew32 -IC:/MinGW/include/GL
我设法让它成功编译。但是,将.a文件放在MinGW / lib中时,源文件夹中的.dll文件和C:\ MinGW \ include中的.h文件并添加
#include "GL/glew.h"
使用以下命令行
g++ -o leaf.exe -Wall physics.cpp -mwindows lib/glut32.lib -lopengl32 -lglu32 -lglfw3dll -lglew32 -IC:/MinGW/include/GL
然后我得到一长串错误,包括:
In file included from physics.cpp:6:0:
c:\mingw\include\gl\glew.h:85:2: error: #error gl.h included before glew.h
#error gl.h included before glew.h
In file included from physics.cpp:6:0:
c:\mingw\include\gl\glew.h:1814:94: error: 'GLchar' does not name a type
typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name);
我第一次尝试在不使用Visual Studio或Eclipse的情况下制作东西。我在这里找到了很多修复工具,但我没有找到具体的东西。
感谢您阅读此内容!
答案 0 :(得分:1)
您需要重新订购包含:
#include "GL/glew.h"
#include "GL/glut.h"
#include "GLFW/glfw3.h"
#include "glm/vec3.hpp"
GLFW(和GLUT?)自动包含GL.h,这是GLEW所抱怨的。不确定为什么你在同一个版本中使用GLUT和GLFW,他们并不完全一起......