cmacosgluglx

In C, how do I install GL/glx.h , GL/gl.h and GL/glu.h on Mac OS


I have some code which includes the headers GL/glx.h , GL/gl.h and GL/glu.h . I do not even know what these are, and Google is not a lot of help because there is so much noise in the search results. So (optionally) what are they, but more importantly, how do I install them on a Mac (Mac OS 10.15.4). I have installed other stuff using homebrew so that would be my preference.

EDIT: By renaming the headers to OpenGL/glx.h etc, I can now find gl.h abd glu.h but not glx.h.

This answer openGL glx.h missing form xcode 4 mac lion says "If you install XQuartz you get X11 which has glx.h" but this is not correct, at least not for me. I have installed xquartz using brew, but still cannot find glx.h.

Another site suggested installing Xcode, which I did, but that does not contain glx.h either.


Solution

  • Installing xquartz fixed it. OpenGL (at least the versions I found) is insufficient because it does not include glx.h. The page xquartz.org says, "The XQuartz project is an open-source effort to develop a version of the X.Org X Window System that runs on OS X. Together with supporting libraries and applications, it forms the X11.app that Apple shipped with OS X versions 10.5 through 10.7."

    So I downloaded and installed xquartz, and then compiled with -I/opt/X11/include instead of -I/usr/X11R6/include, and linked with -L/opt/X11/lib instead of -L/usr/X11R6/lib; as suggested at fatal error 'GL/glx.h' file not found on mac after Xquartz is installed ; and it all worked.