2

I am trying to use a glX function (glXSwapIntervalMESA()) but the compiler is returning an undefined reference error.

I have tried linking with X11 and Xext, and glx, though the last library apparently does not exist. libGL includes some entry points for glx, but I would guess that others (e.g. the one I am trying to use) are platform dependent*.

I cannot find anywhere though which will tell me how to find the names of these platform dependent libraries. For a given system, how do I determine the linker settings in order to use glx?

(*I would guess this because I have seen example linker settings with odd library names.)

sebf
  • 2,831
  • 5
  • 32
  • 50
  • 2
    It's an extension you need to dynamically load it. – Richard Critten Mar 09 '15 at 11:58
  • 1
    I'm not sure that nvidia drivers provide that though, if not then try `glXSwapIntervalEXT` or `glXSwapIntervalSGI`. Note as @RichardCritten says, you need to manually "load" the function (having a local function pointer point to it) with like `yourfuncname = glXGetProcAddress("glXSwapIntervalSGI");` (don't forget to provide a proper declaration of `yourfuncname` corresponding to the function you are loading.) – Jite Mar 09 '15 at 12:03
  • Thank you, I missed that completely! glxinfo says that the functionality is supported so I will try and use it this way. If you add that as an answer I will accept. Or, pls downvote if you think the error in the question is too large for it to be useful and I'll delete. There are already 2-3 others on this subject that are useless due to incorrect assumptions I do not want to add to them! – sebf Mar 09 '15 at 12:13

1 Answers1

3

The function you want to use is an extension function, and you will need to dynamically load it to a function pointer. I would suggest using any one the available extension loader libraries (glew, gl3w, glad...) to help simplifying this process. Alternatively, consider a higher level library like SDL which takes care of a lot of things for you, which should include swapping like in this case.