title: Linux GLEW with GLX segfault (core dumped)
body: <p>I am trying to set up in Linux a very basic program with OpenGL 3.2 core profile, and GLEW. I tried that with the help of this <a href="http://renderingpipeline.com/2012/05/windowless-opengl/" rel="nofollow">article</a>.</p>
  
  <p>This is my code:</p>
  
  <pre><code>#define GLEW_STATIC
  #include &lt;iostream&gt;
  #include &lt;cstdio&gt;
  #include &lt;string&gt;
  #include &lt;GL/glew.h&gt;
  #include &lt;X11/Xlib.h&gt;
  #include &lt;X11/Xutil.h&gt;
  #include &lt;GL/gl.h&gt;
  #include &lt;GL/glx.h&gt;
  
  //#include &lt;GL/glut.h&gt;
  #include "stb_image_write.h"
  #include &lt;cstdlib&gt;
  #include &lt;GL/glfw.h&gt;
  
  
  static float _viewPortHeight = 30;
  static float _viewPortWidth = 10;
  
  typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
  typedef Bool (*glXMakeContextCurrentARBProc)(Display*, GLXDrawable, GLXDrawable, GLXContext);
  static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = NULL;
  static glXMakeContextCurrentARBProc   glXMakeContextCurrentARB   = NULL;
  
  int main (int argc, char *argv[]){
      glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );
      glXMakeContextCurrentARB   = (glXMakeContextCurrentARBProc)   glXGetProcAddressARB( (const GLubyte *) "glXMakeContextCurrent");
      Display *display = XOpenDisplay(NULL);
      if (display == NULL){
          std::cout  &lt;&lt; "error getting the X display";
          return -1;
       }
  
      static int visualAttribs[] = {None};
      int numberOfFrameBufferConfigurations;
      GLXFBConfig *fbConfigs = glXChooseFBConfig(display, DefaultScreen(display), visualAttribs, &amp;numberOfFrameBufferConfigurations);
  
       int context_attribs[] = {
            GLX_CONTEXT_MAJOR_VERSION_ARB ,3,
            GLX_CONTEXT_MINOR_VERSION_ARB, 2,
            GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
            GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,None
       };
  
      std::cout &lt;&lt; "initialising context...";
      GLXContext openGLContext = glXCreateContextAttribsARB(display, fbConfigs[0], 0, True, context_attribs);
  
      int pBufferAttribs[] = {
          GLX_PBUFFER_WIDTH, 32,
          GLX_PBUFFER_HEIGHT, 32,
          None
      };
  
      GLXPbuffer pbuffer = glXCreatePbuffer(display, fbConfigs[0], pBufferAttribs);
      XFree(fbConfigs);
      XSync(display, False);
      if(!glXMakeContextCurrent(display, pbuffer, pbuffer, openGLContext)){
          std::cout &lt;&lt; "error with content creation";
          return -1;
      }
      glXMakeCurrent(display, pbuffer, openGLContext);
  
      GLenum error = glewInit();
      if (error != GLEW_OK){
         std::cout &lt;&lt; "error with glew init()\n";
      }else{
          std::cout &lt;&lt; "glew is ok\n\n";
      }
      GLuint test;
      GLuint framebuffer;
      glGenFramebuffers(1, &amp;framebuffer);
  
      glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
      glClear(GL_COLOR_BUFFER_BIT);
  
      std::string path("output.png");
      exportToPath(path);
  
      return 0;
   }
  </code></pre>
  
  <p>The output I get is this:</p>
  
  <blockquote>
    <p>Initialising context... glew is ok</p>
    
    <p>Segmentation Fault (core dumped)</p>
  </blockquote>
  
  <p>The line that is causing the problem is at the <code>glGenFrameBuffers</code> call, which is also the first call to the functions produced by GLEW. Something is very wrong here, but I can't seem to figure out what and why.</p>
  
  <p>Can anyone point me in the right direction?</p>