Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when I use the line #include <OpenGL/gl.h> in my xcode project, where does it look for the gl.h file?

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.

like image 434
bernie2436 Avatar asked Feb 02 '26 21:02

bernie2436


2 Answers

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.

like image 183
Carl Norum Avatar answered Feb 04 '26 10:02

Carl Norum


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.

like image 22
Tommy Avatar answered Feb 04 '26 09:02

Tommy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!