I have this project were I'm trying to compile some shaders, I have included a various set of libs mainly:
#include <GL/glew.h>
#include <GL/glut.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysymdef.h>
#include <GL/glx.h>
// #include <GL/gl.h>
// #include <GL/glu.h>
It do be more but they are irrelevant. And also I do have all these header files.
The error I get is stated as below:
/usr/bin/ld: /tmp/ccAk1JLH.o: warning: relocation against `__glewCompileShader' in read-only section `.text'
/usr/bin/ld: /tmp/ccAk1JLH.o: in function `load_shaders(unsigned int&)':
/home/vigor/school/prog1/RicochetRobots/src/main.cpp:139: undefined reference to `__glewCreateShader'
/usr/bin/ld: /home/vigor/school/prog1/RicochetRobots/src/main.cpp:141: undefined reference to `__glewShaderSource'
/usr/bin/ld: /home/vigor/school/prog1/RicochetRobots/src/main.cpp:142: undefined reference to `__glewCompileShader'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [Makefile:30: main] Error 1
This is my compile command:
g++ -g -Wall -o _build/main src/main.cpp -I/opt/x11/include -L/usr/x11/lib -I./include -I./inc -I./inc/glm -lGL -lX11
This error you can see above probably has to do with the lines:
GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
const GLchar* vertSrc = src.c_str();
glShaderSource( vertexShader, 1, &vertSrc, NULL );
glCompileShader( vertexShader );
But as you can see I never wrote glewCreateShader which my linker is complaining about.
How can I resolve this?
OS:
Linux kali 5.9.0-kali4-amd64 #1 SMP Debian 5.9.11-1kali1 (2020-12-01) x86_64 GNU/Linux