0

For a GUI project, we have a makefile which builds a library (.a) from all the .o files, which is then linked for each test.

When doing so, any function not used is thus not included in the executable. In order not to have to rebuild every test every time, we decided to switch to .so and use dynamic linking. This code uses OpenGL and glad.o (glad.c --> glad.o)

libgrail.so: undefined reference to `glad_glProgramBinary'
libgrail.so: undefined reference to `glad_glGetProgramBinary'

I had a glad.o, and not even sure how we got it. It has the above symbols defined, but it is not compiled with -fPIC and cannot be linked into the shared library.

When I build with glad.c, the resulting glad.o does NOT have the symbols

Looking at the header file glad.h

GLAPI PFNGLPROGRAMBINARYPROC glad_glProgramBinary;
#define glProgramBinary glad_glProgramBinary

These are called in compiling shaders.

So perhaps our source of glad.c is bad. I looked all over, and can find it in various opengl demos, but I do not understand where it really comes from.

I found this generator: https://glad.dav1d.de/

and generated code for OpenGL 3.3 (.c and .h) compiling that code has the same errors. So what version of glad.c should I get in order to correctly generate these symbols?

Dov
  • 8,000
  • 8
  • 46
  • 75
  • How is `libgrail.so` compiled and linked? – Botje Oct 14 '19 at 11:26
  • I found the source of the error is glad.c itself and have edited the question accordingly. I was just using a glad.o that worked, but generating from source is not working. Nothing to do with the link per se. – Dov Oct 14 '19 at 11:47
  • You are supposed to use the generator at the URL you linked to generate working bindings. The [documentation](https://www.khronos.org/opengl/wiki/GLAPI/glProgramBinary) shows that this function is core from OpenGL 4.1 on, possibly with the ARB_get_program_binary extension. – Botje Oct 14 '19 at 11:52
  • Right! I copied in .h and .c from Opengl4.2 and everything worked.Thanks! – Dov Oct 14 '19 at 11:57

0 Answers0