未定义的引用`__glewCreateShader`

时间:2016-06-02 04:52:41

标签: c++ opengl glew

#ifdef _WIN32
#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/glu.h>
#else
...
#endif
#include <SDL2/SDL.h>
#include <box2d/box2d.h>

在开始使用glewInit, glDrawArrays...之前,所有内容(如glCreateShader, glShaderSource, glCompileShader, glAttachShader, glLinkProgram)都运行良好。现在,编译器向我显示了这些错误:

>g++ -std=c++14 b.cpp -lbox2d -lmingw32 -lsdl2main -lsdl2 -lglew32 -lopengl32 -o b.exe

b.cpp:(.text+0xcff): undefined reference to `__glewCreateShader'
b.cpp:(.text+0xd50): undefined reference to `__glewShaderSource'
b.cpp:(.text+0xd78): undefined reference to `__glewCompileShader'
b.cpp:(.text+0xd88): undefined reference to `__glewCreateProgram'
b.cpp:(.text+0xd95): undefined reference to `__glewAttachShader'
b.cpp:(.text+0xdaf): undefined reference to `__glewLinkProgram'
collect2.exe: error: ld returned 1 exit status

我正在使用glew 1.13.0 Win32和SDL2-i686-w64-mingw32。我该怎么办?

2 个答案:

答案 0 :(得分:0)

由于您使用的是MinGW,因此您可能需要与-lGLEW而不是-lglew32相关联。

答案 1 :(得分:-1)

嗯,这完成了这项工作。

#ifdef _WIN32
#define GLEW_STATIC
#include "glew.c"   //I've brought glew.c from glew source folder
#else
...
#endif
...