我在Windows7 64位笔记本电脑(HP Pavilion g6)上运行Visual Studio2010专业版
非官方OpenGL SDK:http://glsdk.sourceforge.net/docs/html/index.html
非官方的OpenGL SDK、GLew和GLee都是最新的,在适当的地方都有匹配的驱动程序、库和头文件。
设置:
Preprocessor either over the entire project OR over the main.c file: GLEW_STATIC
Additional Include Directories:
C:/glsdk_0.4.2/glload/include;C:/glsdk_0.4.2/glimg/include;C:/glsdk_0.4.2/glutil/include;C:/glsdk_0.4.2/glmesh/include;C:/glsdk_0.4.2/glm;C:/glsdk_0.4.2/glfw/include;C:/glsdk_0.4.2/freeglut/include;
Additional Library Directories:
C:/glsdk_0.4.2/glload/lib;C:/glsdk_0.4.2/glimg/lib;C:/glsdk_0.4.2/glutil/lib;C:/glsdk_0.4.2/glmesh/lib;C:/glsdk_0.4.2/glfw/library;C:/glsdk_0.4.2/freeglut/lib;
Also tried adding C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib/glew32s.lib (or glew32, glew32mx & glew32mxs);C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib/OpenGL32.lib; in Linker -> Input -> Additional Dependancies
Path Inputs (Changed through Environment Variables. Excluding irrelevant entries):
C:\glsdk_0.4.2\glutil\lib;C:\glsdk_0.4.2\freeglut\lib;C:\glsdk_0.4.2\glfw\library;C:\glsdk_0.4.2\glload\lib;C:\glsdk_0.4.2\glimg\lib;
GLew & GLee lib files are located in:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
Also tried with them located at:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
GLew & GLee header files are located in:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\GL
Also tried with them located at:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\GL从ISBN10 -0-321-33679-8 "OpenGL Distilled“复制的代码(标题除外):
#include <stdio.h>
#include <math.h>
// Uncomment for GLee ( Also comment out glutInit(&argc, argv); )
//#include <GL\GLee.h>
// Uncomment for GLew
/*#include <GL\glew.h>
#include <GL\wglew.h>
#include <GL\glut.h>
#include <GL\glext.h> */
// Uncomment for all headers in the "Unofficial OpenGL SDK"
/*#include <glload\gl_all.h>
#include <GL\glut.h>
#include <glload\gll.h>
#include <glimg\glimg.h>
#include <glutil\glutil.h>
#include <glmesh\glmesh.h>
#include <GL\glfw.h>
#define FREEGLUT_STATIC
#define _LIB
#define FREEGLUT_LIB_PRAGMAS 0
#include <GL\freeglut.h> */
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
// Obtain a buffer identifier from OpenGL
GLuint bufferID = 0;
glGenBuffers( 1, &bufferID );
// Bind the buffer object, OpenGL initially creates it empty.
glBindBuffer( GL_ARRAY_BUFFER, bufferID );
// Define three vertices to draw a right angle triangle.
const GLfloat vertices[] = [
0.f, 0.f, 0.f,
1.f, 0.f, 0.f,
0.f, 1.f, 0.f };
// Tell OpenGL to copy data from the 'vertices' pointer into
// the buffer object
glBufferData(GL_ARRAY_BUFFER, 3*3*sizeof(GLfloat), vertices, GL_STATIC_DRAW );
return 0;
}错误:
With GLee:
1>gl_crap3.obj : error LNK2001: unresolved external symbol _GLeeFuncPtr_glBufferData
1>gl_crap3.obj : error LNK2001: unresolved external symbol _GLeeFuncPtr_glBindBuffer
1>gl_crap3.obj : error LNK2001: unresolved external symbol _GLeeFuncPtr_glGenBuffers
With the Unofficial OpenGL SDK:
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___gleBufferData
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___gleBindBuffer
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___gleGenBuffers
With GLew:
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___glewBufferData
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___glewBindBuffer
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___glewGenBuffers发布于 2012-08-02 23:39:52
对于SDK,您的Visual Studio项目应该具有以下设置(其中sdkbase是您解压并编译SDK的目录的路径)。
C/C++->General->Additional Include Directories
sdkbase\glload\include;sdkbase\glimg\include;sdkbase\glutil\include;sdkbase\glmesh\include;sdkbase\glm;sdkbase\freeglut\include;sdkbase\glfw\includeLinker->General->Additional Library Directories
sdkbase\glload\lib;sdkbase\glimg\lib;sdkbase\glutil\lib;sdkbase\glmesh\lib;sdkbase\freeglut\lib;sdkbase\glfw\libraryLinker->Input/Additional Dependencies,用于调试版本:
glloadD.lib glimgD.lib glutilD.lib glmeshD.lib freeglutD.lib glfwD.lib glu32.lib opengl32.lib gdi32.lib winmm.lib user32.lib对于发布版本:
glload.lib glimg.lib glutil.lib glmesh.lib freeglut.lib glfw.lib glu32.lib opengl32.lib gdi32.lib winmm.lib user32.lib发布于 2012-10-09 12:07:08
对于不使用非官方GLEW的人,我刚刚遇到了这个问题,多亏了Nicol Bolas的回答,我意识到我需要OpenGL的调试库。
对于Visual Studio,我修复了这个问题,将项目调试配置中的glew32.lib -在linker->input/Additional Dependencies中-替换为glew32s.lib (注意末尾的s )。
在我这样做之后,一切都运行得很好。
便笺
虽然您可以在没有此修复的情况下初始化GLEW并使用GLEW特定函数,但是一旦您开始调用OpenGL,在使用调试符号进行构建时,您可能会收到错误。
https://stackoverflow.com/questions/11768770
复制相似问题