0

My Program in OpenGL on a Linux system (Ubuntu) has the following problem. I am unable to understand.

CODE :

#include <iostream>

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

int main(void)
{
   glewExperimental = GL_TRUE;

   if(glewInit() != GLEW_OK)
   {
      std::cerr<<"GLEW Initialization failed"<<std::endl;
      return -1;
   }

   return 0;
}

ERROR :

/tmp/ccw4KIKB.o: In function `main':
Experimental.cpp:(.text+0x6): undefined reference to `glewExperimental'
Experimental.cpp:(.text+0xc): undefined reference to `glewInit'
collect2: error: ld returned 1 exit status 

COMPILING :

g++ Experimental.cpp -lglfw -lGL 
  • Try `-lglfw3` instead of `-lglfw` – itzFlubby Jan 18 '20 at 14:09
  • Try adding `-lGLEW` to your compile/link command. – G.M. Jan 18 '20 at 14:45
  • @G.M. I have no idea how or why but using `-lGLEW` works. Could you kindly tell me as to why this is happening? Because there is no directory named **GLEW** in my **_include_** directory. – Atish Pratap Singh Rathour Jan 18 '20 at 15:58
  • @AtishPratapSinghRathour Just as you need to link with `libglfw` to get `glfwCreateWindow` etc., so you need to link with `libGLEW` to get functions such as `glewInit` and so on. – G.M. Jan 18 '20 at 17:20

0 Answers0