Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/151.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用代码块将GLEW链接到SFML项目时出现的问题_C++_Opengl_Codeblocks_Sfml_Glew - Fatal编程技术网

C++ 使用代码块将GLEW链接到SFML项目时出现的问题

C++ 使用代码块将GLEW链接到SFML项目时出现的问题,c++,opengl,codeblocks,sfml,glew,C++,Opengl,Codeblocks,Sfml,Glew,因此,我正在尝试编写着色器,并将它们合并到我的OpenGL程序中(我使用SFML 1.6创建有效的OpenGL环境,而不是使用GLUT;我的IDE是代码块;我的卡支持OpenGL 3.1和GLSL 1.3)。然而,我遇到了一个障碍;看起来我需要GLEW来帮助将GLSL着色器合并到我的程序中。因此,我找到了GLEW的源代码,并按照最后一条评论的说明,使用代码块将其编译为静态库(我在c.文件中添加了#define GLEW_static,因为我不清楚应该在哪里添加它),因此我现在有四个.a文件: l

因此,我正在尝试编写着色器,并将它们合并到我的OpenGL程序中(我使用SFML 1.6创建有效的OpenGL环境,而不是使用GLUT;我的IDE是代码块;我的卡支持OpenGL 3.1和GLSL 1.3)。然而,我遇到了一个障碍;看起来我需要GLEW来帮助将GLSL着色器合并到我的程序中。因此,我找到了GLEW的源代码,并按照最后一条评论的说明,使用代码块将其编译为静态库(我在c.文件中添加了
#define GLEW_static
,因为我不清楚应该在哪里添加它),因此我现在有四个.a文件:

libglew32.a、libglew32d.a、libglew32mx.a、libglew32mxd.a

我已经告诉我的编译器在哪里可以找到头文件(glew.h、glxew.h、wglew.h),并且我已经告诉链接器在哪里可以找到库(如上),方法是将相关目录添加到设置->编译器和调试器…->搜索目录。在我的项目中,在“构建选项->链接器设置->链接库”下,我还链接了上面四个

执行上述所有操作时,我在尝试调用glewInit()时遇到以下错误:

对“\u imp\u\u glewInit”的未定义引用

有人告诉我,我需要在包含之前添加
#define GLEW_STATIC
,所以我这样做了,现在我得到了大量未定义的引用”wglGetProcAddress@4“错误(我的程序中唯一一行GLEW代码是
glewInit();
):

我不知所措;所有这些(链接/编译/等等)的技术方面对我来说仍然是新的和令人困惑的


为了让GLEW正常工作,我需要做什么,以便将GLSL着色器合并到我的SFML OpenGL项目中?(或者,如果没有GLEW或任何其他外部库,我可以更轻松地实现这一点吗?这太棒了!)

您还需要链接opengl32.lib。链接器抱怨缺少的那些函数是opengl32.dll的一部分,要访问它,需要针对它进行链接。不是在静态库中,而是在最终程序中。从技术上讲,静态库与目标文件的归档不同,即编译阶段的结果。链接到DLL需要在可执行二进制文件的上下文中进行

 Design\Learning C++\OPEN-GL\OpenGL Experiment 6 - 27-block Terrain Test\main.cpp||In function 'int main()':|
 Design\Learning C++\OPEN-GL\OpenGL Experiment 6 - 27-block Terrain Test\main.cpp|43|warning: unused variable 'LightOn'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `glGetString@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| more undefined references to `wglGetProcAddress@4' follow|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetCurrentDC@0'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| more undefined references to `wglGetProcAddress@4' follow|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `glGetString@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `glGetString@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetProcAddress@4'|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| more undefined references to `wglGetProcAddress@4' follow|
C:\Program Files (x86)\CodeBlocks\MinGW\downloaded\glew-1.7.0\afiles\libglew32.a(glew.o):glew.c|| undefined reference to `wglGetCurrentDC@0'|
||=== Build finished: 23 errors, 1 warnings ===|