I am porting an open source C++ program for linux to os x. I have been changing lines from this
#include <GL/gl.h>
to this
#include <OpenGL/gl.h>
based on the advice from this post: How do I use Open GL in a C++ project that I am porting from Linux
That change gets rid of the compiler errors, but I am confused: where is xcode/the C++ compiler that it uses going to look for that file? If I search my xcode project, I don't see a directory called OpenGL or a file = gl.h?
I'm used to including images or javascript libraries in web pages based on the working directory of the .html file. Something else is happening in xcode here.
On a Mac, you'll get those headers from the OpenGL framework. The headers are located at:
/System/Library/Frameworks/OpenGL.framework/Headers
Strictly speaking, that path is a symbolic link - the real location is:
/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
Your toolchain will be able to find them if you pass -framework OpenGL on the compiler/linker command lines.
If you've added the OpenGL framework to your project then Xcode will resolve OpenGL/ as "the headers folder for the current version within the OpenGL.framework". The files aren't copied into your project and you don't need to worry about where the frameworks are stored on disk or how they're laid out internally.
As of Xcode 5, if you have module support enabled you can just use @import OpenGL; both to include the symbols in that compiler unit and ensure the framework is included later by the linker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With