title: glewInit() Failed, OpenGL App
body: <p>I'm trying to build an OpenGL App with glew/glfw. I've downloaded the binaries, placed them in the root of my folder, added the paths to the include and lib directories and told my project to require glew32.lib, GLFW.lib and opengl32.lib. </p>
  
  <p>I even copied glew32.lib to the root directory because my project couldn't see it.</p>
  
  <p>I must keep all the dependencies in the project directory since I will be distributing this. I'm at a loss.</p>
  
  <p>Now when I run my program, it fails at glewInit()</p>
  
  <p>This is my implementation so far:</p>
  
  <pre><code>#include "Common.h"
  
  GameEngine::GameEngine()
  {
      InitWithSize(1024, 768);
      InitInput();
  }
  
  void GameEngine::InitWithSize(int _width, int _height)
  {
      try {
          // Initialise GLFW
          if( !glfwInit() )
              throw std::exception("Failed to initialize GLFW\n");
  
          //glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
          glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); 
          glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
          glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  
          // Open a window and create its OpenGL context
          if( !glfwOpenWindow( _width, _height, 0,0,0,0, 32,0, GLFW_WINDOW ) ) 
              throw std::exception("Failed to initialize GLFW\n");
  
  
          glfwSetWindowTitle( "Tutorial 01" );
  
          // Initialize GLEW
          if (glewInit() != GLEW_OK)
              throw std::exception("Failed to initialize GLEW\n");
  
  
      } catch ( std::system_error const&amp; err) {
          fprintf(stdout, "System Error: %s", err.what());
          glfwTerminate(); // Free glfw if it has been allocated
          // Try Again
          this-&gt;InitWithSize(_width, _height);
      } catch( std::exception const&amp; err) {
          fprintf(stdout, "Exception Found: %s", err.what());
      } catch ( ... ) {
          fprintf(stdout,"Unknown Exception Occurred\n");
      }
  }
  
  void GameEngine::InitInput()
  {
          // Ensure we can capture the escape key being pressed below
          glfwEnable( GLFW_STICKY_KEYS );
  }
  
  void GameEngine::StartGameLoop()
  {
      do{
              // Draw nothing, see you in tutorial 2 !
  
              // Swap buffers
              glfwSwapBuffers();
  
          } // Check if the ESC key was pressed or the window was closed
          while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &amp;&amp;
              glfwGetWindowParam( GLFW_OPENED ) );
  }
  
  
  void GameEngine::InitTestData()
  {
      // An array of 3 vectors which represents 3 vertices
      static const GLfloat g_vertex_buffer_data[] = {
          -1.0f, -1.0f, 0.0f,
          1.0f, -1.0f, 0.0f,
          0.0f,  1.0f, 0.0f,
      };
  
  }
  </code></pre>
  
  <p>With my Common Header:</p>
  
  <pre><code>#ifndef _COMMON_H
  #define _COMMON_H
  
  // OpenGL Libraries
  #define GLEW_STATIC
  //#pragma comment(lib, "glew32.lib")
  #include &lt;GL\glew.h&gt;
  #include &lt;GL\glfw.h&gt;
  
  // Core Libraries
  #include &lt;Windows.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;map&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  
  // C++ 11 Libraries
  #include &lt;memory&gt;
  #include &lt;exception&gt;
  #include &lt;thread&gt;
  #include &lt;chrono&gt;
  
  // Manager Classes
  #include "ThreadManager.h"
  #include "GameEngine.h"
  #include "ShaderManager.h"
  
  // Lesser Classes
  #include "Shader.h"
  
  #endif
  </code></pre>