[英]Linking GLEW libraries when compiling with MinGW
我正在嘗試編寫一個通過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文件放在源文件夾中,並將.h文件放在C:\\ MinGW \\ include中,然后添加
#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的情況下做某事。 我在這里嘗試了很多修復程序,但沒有具體內容。
感謝您閱讀本文!
您需要重新排序您的包含項:
#include "GL/glew.h"
#include "GL/glut.h"
#include "GLFW/glfw3.h"
#include "glm/vec3.hpp"
GLFW(和GLUT?)自動包含GL.h,這正是GLEW抱怨的地方。 不知道為什么您在同一版本中使用GLUT和GLFW,它們不能完全結合在一起...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.