1.OpenGL部分头文件包含顺序问题
#include "stdafx.h"
#include <gl/glew.h>#include <gl/glew.h>
编译后出错
错误 1
error C1189: #error : gl.h included before glew.h
2
IntelliSense: #error 指令: gl.h included before glew.h
解决办法:
#include "stdafx.h"
#include <gl/glew.h>
#include <gl/glut.h>
2.lib文件链接问题
#include <gl/glew.h>
编译出错:
primrestart.obj : error LNK2001: 无法解析的外部符号 __imp____glewGenBuffers
primrestart.exe : fatal error LNK1120: 1 个无法解析的外部命令
解决办法:
右键单击项目——>属性——>配置链接器——>附加依赖项,添加glew的lib文件:glew32.lib,glew32mx.lib,glew32mxs.lib,glew32s.lib
本文解决了OpenGL项目中常见的两个问题:头文件包含顺序错误导致的编译失败,以及未正确链接GLEW库导致的未解析外部符号错误。通过调整头文件的包含顺序和正确配置项目的链接设置,可以有效避免这些常见问题。
1068

被折叠的 条评论
为什么被折叠?



