I am developing a static library that takes screenshots, and their use from OpenGL applications requires special processing.
When a client application references my static library, it should add the frameworks used by my library, for example, to take screenshots of OpenGL, even if the client application does not use OpenGL, it should link to OpenGLES.framework, which is bad. I am trying to check the library if the client has contacted OpenGLES.framework and dynamically allows you to take screenshots from OpenGL.
The problem is that I get a compilation error when I try to use C functions, such as:
if(&glReadPixels != NULL) {
glReadPixels(0, 0, size.width, size.height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
}
As you can see, I can check the existence of the method, but how can I call it so as not to cause a linker error? When I compile the client with my library, I get the following:
Undefined symbols for architecture i386:
"_glReadPixels", referenced from:
+[TakeScreenshotUtil takeOpenGLScreenshotWithContext:layerSize:] in libScr-iOS.a(TakeScreenshotUtil.o)
I'm trying to use
__attribute__ ((weak))
but it does not work (does not change anything).
source
share