1

my.cpp file has #import <OpenGLES/ES2/glext.h>. I am trying to compile it by g++ -c my.cpp which fails with fatal error: 'OpenGLES/ES2/glext.h' file not found #import <OpenGLES/ES2/glext.h>

I am able to compile it from Xcode with GLKit.framework. How to compile it in macOS from command line?

--EDIT--

Where are the OpenGL header files located on MacOSX? seems relevant but it is to OpenGL. I am looking for OpenGL ES

The include path shown by Xcode is

enter image description here

but I couldn't figure out its location in the file system to use with compiler's -I option

Community
  • 1
  • 1
Necktwi
  • 2,483
  • 7
  • 39
  • 62
  • Is `OpenGLES/ES2/glext.h` in a place the compiler will look for? Some good reading: http://stackoverflow.com/questions/344317/where-does-gcc-look-for-c-and-c-header-files – NathanOliver Apr 26 '17 at 18:36
  • Don't know the path of it. I have edited the question regarding it – Necktwi Apr 26 '17 at 22:50
  • I think you can pass the name of the framework to it also `-framework OpenGLES`... – l'L'l Apr 27 '17 at 01:08
  • `clang: warning: -framework OpenGLES: 'linker' input unused [-Wunused-command-line-argument]` `In file included from my.cpp:9:` `./my.hpp:13:9: fatal error: 'OpenGLES/ES2/glext.h' file not found` `#import ` – Necktwi Apr 27 '17 at 04:09

1 Answers1

1

The key to solving would be specifying the OpenGLES location:

g++ -c my.cpp -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhon‌​eOS.platform/Develop‌​er/SDKs/iPhoneOS10.3‌​.sdk/System/Library/‌​Frameworks -framework OpenGLES

The -F flag indicates the library location, and -framework indicates which framework to use.

Technically -isysroot could work as well:

g++ -c my.cpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhon‌​eOS.platform/Develop‌​er/SDKs/iPhoneOS10.3‌​.sdk
l'L'l
  • 44,951
  • 10
  • 95
  • 146