在64位Ubuntu 14.04 LTS上,我正在尝试编译一个使用过剩的简单OpenGL程序.我在main中执行任何代码行之前得到了一个Segmentation Fault(SIGSEV); 即使是在一个非常简单的测试计划上.什么可能导致这个?
我的命令行:
g ++ -Wall -g main.cpp -lglut -lGL -lGLU -o main
我的简单测试案例:
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <string>
#include <cstdio>
int main(int argc, char** argv){
printf("Started\n");
std::string dummy = "hello";
glutInit(&argc, argv);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我运行程序时,main开头的printf不会在segfault之前执行.在GDB下,我在segfault之后得到了这个回溯
#0 0x0000000000000000 in ?? ()
#1 0x00007ffff3488291 in init () at dlerror.c:177
#2 0x00007ffff34886d7 in _dlerror_run (operate=operate@entry=0x7ffff3488130 <dlsym_doit>, args=args@entry=0x7fffffffddf0) at dlerror.c:129
#3 0x00007ffff3488198 in __dlsym (handle=<optimized out>, name=<optimized out>) at dlsym.c:70
#4 0x00007ffff702628e in ?? () from …Run Code Online (Sandbox Code Playgroud)