Error Compiling "simple.c" using gcc

Hi, I’m just starting out with glfw on CentOS and tried compiling “simple.c” program using gcc (because the application I intend to use it in compiles using gcc) but I’m getting the following error:

[root@localhost brlcad-viewer]# gcc -o simple simple.c -lglfw3 -lGL -lm -lXrandr -lXi -lX11 -lXxf86vm -lpthread -ldl -lXinerama -lXcursor
/tmp/ccm0ahtk.o: In function main': simple.c:(.text+0x585): undefined reference togladLoadGLLoader’
simple.c:(.text+0x596): undefined reference to `glad_glGenBuffers’

I know it’s something to do with glad but I’ve placed glad.h in the same directory and included it in simple.c

This is not related to glfw.
You simply need to compile & link to glad.c code which contains all the glad* functions. Put glad.c in gcc arguments:

gcc -o simple simple.c glad.c -lglfw3 -lGL -lm -lXrandr -lXi -lX11 -lXxf86vm -lpthread -ldl -lXinerama -lXcursor
1 Like