2017-04-26 42 views
1

my.cpp文件具有#import <OpenGLES/ES2/glext.h>。我試圖通過g++ -c my.cpp進行編譯,其失敗fatal error: 'OpenGLES/ES2/glext.h' file not found #import <OpenGLES/ES2/glext.h>MACOS命令行編譯克++ OpenGL ES的cpp文件

我能夠從Xcode與GLKit.framework編譯它。如何從命令行在macOS中編譯它?

- 編輯 -

Where are the OpenGL header files located on MacOSX?似乎相關,但它是OpenGL。我找OpenGL ES

的包括由Xcode中所示的路徑

enter image description here

,但在文件系統中我無法弄清楚它的位置與編譯器的-I選項

+0

是'OpenGLES/ES2/glext.h'在一個地方,編譯器會尋找?一些很好的閱讀:http://stackoverflow.com/questions/344317/where-does-gcc-look-for-c-and-c-header-files – NathanOliver

+0

不知道它的路徑。我已經編輯把它 – neckTwi

+0

我想你可以框架的名字傳遞給它也'-framework OpenGLES' ... –

回答

1

要使用的密鑰解決將指定OpenGLES位置:

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.

技術上-isysroot可以工作,以及:

g++ -c my.cpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhon‌​eOS.platform/Develop‌​er/SDKs/iPhoneOS10.3‌​.sdk 
+0

這就是我正在尋找。 – neckTwi