title: error LNK2019: unresolved external symbol
body: <p>while i want to compile my opengl code i get the following errors:</p>
  
  <pre><code>Error   1   error LNK2019: unresolved external symbol __imp__glewInit@0 
  Error   2   error LNK2019: unresolved external symbol __imp__glewGetErrorString@4 
  Error   3   error LNK2001: unresolved external symbol __imp____glewAttachShader     
  Error   4   error LNK2001: unresolved external symbol __imp____glewCompileShader    
  Error   5   error LNK2001: unresolved external symbol __imp____glewCreateProgram    
  Error   6   error LNK2001: unresolved external symbol __imp____glewCreateShader 
  Error   7   error LNK2001: unresolved external symbol __imp____glewDeleteProgram    
  Error   8   error LNK2001: unresolved external symbol __imp____glewDisableVertexAttribArray 
  Error   9   error LNK2001: unresolved external symbol __imp____glewEnableVertexAttribArray  
  Error   10  error LNK2001: unresolved external symbol __imp____glewGetAttribLocation    
  Error   11  error LNK2001: unresolved external symbol __imp____glewGetProgramiv 
  Error   12  error LNK2001: unresolved external symbol __imp____glewGetShaderiv  
  Error   13  error LNK2001: unresolved external symbol __imp____glewLinkProgram  
  Error   16  error LNK2001: unresolved external symbol __imp____glewVertexAttribPointer  
  Error   17  error LNK1120: 16 unresolved externals  
  </code></pre>
  
  <p>my code is :</p>
  
  <pre><code>#include &lt;Windows.h&gt;
  #include &lt;iostream&gt;
  #include &lt;glew.h&gt;
  #include &lt;gl\GL.h&gt;
  #include &lt;freeglut.h&gt;
  
  using namespace std;
  
  GLuint program;
  GLint attribute_coord2d;
  
  int init_resources(void)
  {
    GLint compile_ok = GL_FALSE, link_ok = GL_FALSE;
  
    GLuint vs = glCreateShader(GL_VERTEX_SHADER);
    const char *vs_source = 
  #ifdef GL_ES_VERSION_2_0
      "#version 100\n"  // OpenGL ES 2.0
  #else 
      "#version 120\n"  // OpenGL 2.1
  #endif
      "attribute vec2 coord2d;                  "
      "void main(void) {                        "
      "  gl_Position = vec4(coord2d, 0.0, 1.0); "
      "}";
    glShaderSource(vs, 1, &amp;vs_source, NULL);
    glCompileShader(vs);
    glGetShaderiv(vs, GL_COMPILE_STATUS, &amp;compile_ok);
    if (0 == compile_ok)
    {
      fprintf(stderr, "Error in vertex shader\n");
      return 0;
    }
  
     GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
    const char *fs_source =
      "#version 120           \n"
      "void main(void) {        "
      "  gl_FragColor[0] = 0.0; "
      "  gl_FragColor[1] = 0.0; "
      "  gl_FragColor[2] = 1.0; "
      "}";
    glShaderSource(fs, 1, &amp;fs_source, NULL);
    glCompileShader(fs);
    glGetShaderiv(fs, GL_COMPILE_STATUS, &amp;compile_ok);
    if (!compile_ok) {
      fprintf(stderr, "Error in fragment shader\n");
      return 0;
    }
  
     program = glCreateProgram();
    glAttachShader(program, vs);
    glAttachShader(program, fs);
    glLinkProgram(program);
    glGetProgramiv(program, GL_LINK_STATUS, &amp;link_ok);
    if (!link_ok) {
      fprintf(stderr, "glLinkProgram:");
      return 0;
    }
  
      const char* attribute_name = "coord2d";
    attribute_coord2d = glGetAttribLocation(program, attribute_name);
    if (attribute_coord2d == -1) {
      fprintf(stderr, "Could not bind attribute %s\n", attribute_name);
      return 0;
    }
  
    return 1;
  }
  
  void onDisplay()
  {
    /* Clear the background as white */
    glClearColor(1.0, 1.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);
  
    glUseProgram(program);
    glEnableVertexAttribArray(attribute_coord2d);
    GLfloat triangle_vertices[] = {
       0.0,  0.8,
      -0.8, -0.8,
       0.8, -0.8,
    };
    /* Describe our vertices array to OpenGL (it can't guess its format automatically) */
    glVertexAttribPointer(
      attribute_coord2d, // attribute
      2,                 // number of elements per vertex, here (x,y)
      GL_FLOAT,          // the type of each element
      GL_FALSE,          // take our values as-is
      0,                 // no extra data between each position
      triangle_vertices  // pointer to the C array
    );
  
    /* Push each element in buffer_vertices to the vertex shader */
    glDrawArrays(GL_TRIANGLES, 0, 3);
    glDisableVertexAttribArray(attribute_coord2d);
  
    /* Display the result */
    glutSwapBuffers();
  }
  
  void free_resources()
  {
    glDeleteProgram(program);
  }
  
  
  int main(int argc, char* argv[])
  {
    /* Glut-related initialising functions */
    glutInit(&amp;argc, argv);
    glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
    glutInitWindowSize(640, 480);
    glutCreateWindow("My First Triangle");
  
    /* Extension wrangler initialising */
    GLenum glew_status = glewInit();
    if (glew_status != GLEW_OK)
    {
      fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
      return EXIT_FAILURE;
    }
  
    /* When all init functions runs without errors,
    the program can initialise the resources */
    if (1 == init_resources())
    {
      /* We can display it if everything goes OK */
      glutDisplayFunc(onDisplay);
      glutMainLoop();
    }
  
    /* If the program exits in the usual way,
    free resources and exit with a success */
    free_resources();
    return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>i tried every thing from tweaking linker option including .lib files explicitly, specifying include paths reading forums related to these errors and so on, none of them helped, can you guys help me how i fix this problem? </p>