glewInit() fails on macOS

后端 未结 1 409
无人共我
无人共我 2021-01-05 16:17

So I have a piece of code that runs fine on ubuntu machine, but fails to do so on xcode or via terminal. I\'m trying to run it on xcode, but it fails on main with:

\

相关标签:
1条回答
  • 2021-01-05 17:20

    glewInit() call (and the includes, of course) is not necessary on MacOS, so you might just exclude it this way:

    #ifndef __APPLE__
    glewInit();
    #endif
    

    The same with includes.

    Now with the unresolved symbols. You have to include MacOSX's native GL headers:

    #ifdef __APPLE__
    #  include <OpenGL/gl.h>
    #  include <OpenGL/glext.h>
    #else /// your stuff for linux
    #  include "GL/GL.h"
    .... whatever
    #endif
    

    OpenGL is a core technology for OSX, not an "extension", as in Linux/X Window. So just include the OpenGL and GLUT framework to your XCode project and hopefully it should build and work.

    0 讨论(0)
提交回复
热议问题