title: VisualStudio2010 OpenGL project crashes with 0x000007b right on start
body: <p>I try to setup a simple VisualStudio2010 OpenGL Project</p>
  
  <p>I start with a new Win32 project and replace _tWinMain with the following:</p>
  
  <pre><code>int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
  {
      UNREFERENCED_PARAMETER(hPrevInstance);
      UNREFERENCED_PARAMETER(lpCmdLine);
  
      // TODO: Place code here.
      //MSG msg;
      HACCEL hAccelTable;
  
      // Initialize global strings
      LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
      LoadString(hInstance, IDC_GLPREDICTOR, szWindowClass, MAX_LOADSTRING);
      MyRegisterClass(hInstance);
  
      // Perform application initialization:
      if (!InitInstance (hInstance, nCmdShow))
      {
          return FALSE;
      }
  
      HDC hdc = GetDC(hWnd);
      if (hdc == NULL)
          return FALSE;
      if(!SetPF(hdc))
          return FALSE;
  
      mainApp = new GLPredictor(hdc);
  
      HGLRC tmpContext = wglCreateContext (hdc);
      wglMakeCurrent(hdc, tmpContext);
  
      //create opengl 4.2 context
      /*GLenum error = glewInit();
      if(error != GLEW_OK)
          return false;
      int attributes[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
                          WGL_CONTEXT_MINOR_VERSION_ARB, 2,
                          WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
                          0
                          };
  
      if(wglewIsSupported("WGL_ARB_create_context")==1){
          HGLRC context = wglCreateContextAttribsARB(hdc, NULL,attributes);
          wglMakeCurrent(NULL, NULL);
          wglDeleteContext(tmpContext);
          wglMakeCurrent(hdc,context);
      }
      else{
          return FALSE;
      }
  
      int glVersion[2] = {-1,-1};
      glGetIntegerv(GL_MAJOR_VERSION, &amp;glVersion[0]);
      glGetIntegerv(GL_MINOR_VERSION, &amp;glVersion[1]);
      std::cout&lt;&lt;"Using OpenGL: "&lt;&lt;glVersion[0]&lt;&lt;"."&lt;&lt;glVersion[1]&lt;&lt;std::endl;
      */
  
      hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_GLPREDICTOR));
  
      MSG msg = {0};
      while(TRUE)
      {
          // Check to see if any messages are waiting in the queue
          if(PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))
          {
              TranslateMessage(&amp;msg);
              DispatchMessage(&amp;msg);
              if(msg.message == WM_QUIT)
                  break;
          }
          else
          {
              mainApp-&gt;render();
          }
      }
  
      return (int) msg.wParam;
  }
  </code></pre>
  
  <p>This runs.</p>
  
  <p>But as soon as i uncomment the commented region (//create opengl 4.2 context) and try to run the app, then i get instantly an error message saying:</p>
  
  <pre><code>The application was unable to start correctly (0x000007b). Click OK to close the application.
  </code></pre>
  
  <p>but the uncommented code isn't even reached. I can set a breakpoint even on the first line of _tWinMain and it won't be triggered.</p>
  
  <p>I already tried to create a new project and copy the code over, with the same result.</p>
  
  <p>Anyone got an idea why this region causes the project to crash, even if the code it contains is executed?</p>
  
  <p>//edit: the offending line seems to be </p>
  
  <pre><code> GLenum error = glewInit();
  </code></pre>
  
  <p>as soon as it's in the code, it makes the application crash (although code execution never reaches it). Does this line cause the compiler to add some stuff that may cause the problem?</p>