title: Using glew with SDL2
body: <p>When I want to use SDL2 and glew together I get the following error upon <code>glewInit()</code>:</p>
  
  <blockquote>
    <p>Missing GL version</p>
  </blockquote>
  
  <p>An example that reproduces the error:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #define NO_SDL_GLEXT
  #include &lt;GL/glew.h&gt;
  #include "SDL2/SDL.h"
  #include "SDL/SDL_opengl.h"
  
  int main(int argc, char **argv)
  {
      if(SDL_Init(SDL_INIT_VIDEO) &lt; 0)
      {
          std::cout &lt;&lt; "SDL could not initialize! SDL Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return -1;
      }
      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); // Does nothing
      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); // Does nothing
      SDL_Window *window = SDL_CreateWindow("Example for SO", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL);
      if(window == nullptr)
      {
          std::cout &lt;&lt; "Window could not be created! SDL Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          return -1;
      }
      glewExperimental = GL_TRUE;
      auto init_res = glewInit();
      if(init_res != GLEW_OK)
      {
          std::cout &lt;&lt; glewGetErrorString(glewInit()) &lt;&lt; std::endl;
      }
      SDL_DestroyWindow(window);
      SDL_Quit();
      return 0;
  }
  </code></pre>
  
  <p>Compiled with:</p>
  
  <pre><code>c++ (Debian 6.3.0-11) 6.3.0 (gcc)
  flags: -std=c++17
  libraries:
  -L/usr/local/lib -lSDL2 -Wl,-rpath=/usr/local/lib -lGLEW
  </code></pre>