原因

    默认情况下需要调用函数glutCreateWindow("GLEW Test");指定一个OpenGL的context

代码

#include <GL/glew.h>

#include <GL/glut.h> 

#include <stdio.h>

#include <stdlib.h>

#include <iostream>

using namespace std;

#pragma comment(lib, "glew32.lib") 

int main()

{

  glutCreateWindow("GLEW Test");//get an openGL context  

  GLenum err = glewInit();

  char szMsgErr[1024] = {0};

  if (err != GLEW_OK)

  {

    sprintf(szMsgErr, "Error:%s\n", glewGetErrorString(err));

    return -1;

  }

}