GLEW 1.10:glewInit中的EXC_BAD_ACCESS

时间:2013-08-23 04:00:56

标签: c glew

尝试初始化最近的GLEW,程序中断,lldb给出上述消息。

最小例子:

#define GLEW_STATIC
#include <GL/glew.h>

int main(int argc, const char * argv[]) {
    glewExperimental = GL_TRUE;
    glewInit();    <<<< EXC_BAD_ACCESS here
}

堆栈构成调试器输出:

1 ___lldb_unnamed_function...

libGLEW.1.10.0.dylib`___lldb_unnamed_function2$$libGLEW.1.10.0.dylib:
0x100005e30:  pushq  %rbp
0x100005e31:  movq   %rsp, %rbp
0x100005e34:  pushq  %r15
0x100005e36:  pushq  %r14
0x100005e38:  pushq  %r12
0x100005e3a:  pushq  %rbx
0x100005e3b:  movl   $7938, %edi
0x100005e40:  callq  0x100044668               ; symbol stub for: glGetString
0x100005e45:  movl   $1, %r14d        <<<< EXC_BAD_ACCESS here
0x100005e4b:  testq  %rax, %rax
0x100005e4e:  je     0x100034a86               ; ___lldb_unnamed_function2$$libGLEW.1.10.0.dylib + 191574
...

0 glGetString

libGL.dylib`glGetString:
0x7fff8bfa28a6:  pushq  %rbp
0x7fff8bfa28a7:  movq   %rsp, %rbp
0x7fff8bfa28aa:  movl   %edi, %eax
0x7fff8bfa28ac:  movq   %gs:240, %rdx
0x7fff8bfa28b5:  movq   944(%rdx), %rcx    <<<< EXC_BAD_ACCESS here
0x7fff8bfa28bc:  movq   (%rdx), %rdi
0x7fff8bfa28bf:  movl   %eax, %esi
0x7fff8bfa28c1:  popq   %rbp
0x7fff8bfa28c2:  jmpq   *%rcx

GLEW或我的配置中出现了这个错误吗?

1 个答案:

答案 0 :(得分:3)

显然,首先需要创建gl上下文。

因此,如果是glfw,则glfwCreateWindow需要成功调用glewInit