0

I added glew.h into the project and defined GLEW_STATIC as internet says. Then I tried to add vertex shader to the project but compiler says:

LNK2001 unresolved external symbol ___glewCompileShader. LNK2001unresolved external symbol __glewCreateShader.
LNK2001 unresolved external symbol ___glewShaderSource.

I use x86 Debugging to compile.

Code where error appears:

#define GLEW_STATIC
#include <glew.h>
#include <GLFW/glfw3.h>

#include "flythrough_camera.h"
#include <glut.h>

#include <Windows.h>

#pragma comment(lib, "OpenGL32.lib")
#pragma comment(lib, "glu32.lib")
#include <stdio.h>
#include <math.h>


#define _USE_MATH_DEFINES

const char* vertexShaderSource = "#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
"void main()\n"
"{\n"
"   gl_Position = vec4(aPos, 1.0);\n"
"}\0";

void drawGround() {
    unsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
    glCompileShader(vertexShader);
//Without theese 3 lines program runs with no visible problems
...
}

Internet surfing showed that #define GLEW_STATIC fixes problem but in my case it just makes errors strings less detailed like from this enter image description here

to that:

enter image description here

  • When you build this, do you link in the necessary libraries? Including the required headers will get you through the compilation phase, but if you don't link the libraries, you will get an error during the linking phase. – Chris Dec 28 '21 at 21:20
  • @Chris glew archive from official website has empty folder called lib so I guess I have no libs I need to link. Upd. looks like found one gonna check – Mikkel Ontberg Dec 28 '21 at 21:22

0 Answers0