Question

I'm trying to set up a program using GLEW on OS X 10.9 with Xcode 5.1, but upon trying to build it, I get a huge amount of errors originating from glew.h:

Build target HelloGL

CompileC /Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Intermediates/HelloGL.build/Debug/HelloGL.build/Objects-normal/x86_64/main.o HelloGL/main.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/rpowell/Projects/HelloGL
    export LANG=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fmodules -fmodules-cache-path=/Users/rpowell/Library/Developer/Xcode/DerivedData/ModuleCache -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -mmacosx-version-min=10.9 -g -Wno-sign-conversion -I/Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Intermediates/HelloGL.build/Debug/HelloGL.build/HelloGL.hmap -I/usr/local/include -I/Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Products/Debug/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Intermediates/HelloGL.build/Debug/HelloGL.build/DerivedSources/x86_64 -I/Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Intermediates/HelloGL.build/Debug/HelloGL.build/DerivedSources -F/Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Products/Debug -MMD -MT dependencies -MF /Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Intermediates/HelloGL.build/Debug/HelloGL.build/Objects-normal/x86_64/main.d --serialize-diagnostics /Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Intermediates/HelloGL.build/Debug/HelloGL.build/Objects-normal/x86_64/main.dia -c /Users/rpowell/Projects/HelloGL/HelloGL/main.c -o /Users/rpowell/Library/Developer/Xcode/DerivedData/HelloGL-hkapwtszjscyivcyxfphwntzlxmw/Build/Intermediates/HelloGL.build/Debug/HelloGL.build/Objects-normal/x86_64/main.o

In file included from /Users/rpowell/Projects/HelloGL/HelloGL/main.c:1:
/usr/local/include/GL/glew.h:15043:17: error: declaration of 'PFNGLCOPYTEXSUBIMAGE3DPROC' must be imported from module 'OpenGL.GL3' before it is required
GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D;
                ^
In module 'OpenGL' imported from /usr/local/include/GL/glew.h:1186:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gl3.h:1762:25: note: previous declaration is here
typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
                        ^
In file included from /Users/rpowell/Projects/HelloGL/HelloGL/main.c:1:
/usr/local/include/GL/glew.h:15049:17: error: unknown type name 'PFNGLCLIENTACTIVETEXTUREPROC'; did you mean 'PFNGLACTIVETEXTUREPROC'?
GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLACTIVETEXTUREPROC
In module 'OpenGL' imported from /usr/local/include/GL/glew.h:1186:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gl3.h:1778:25: note: 'PFNGLACTIVETEXTUREPROC' declared here
typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
                        ^
In file included from /Users/rpowell/Projects/HelloGL/HelloGL/main.c:1:
/usr/local/include/GL/glew.h:15057:17: error: unknown type name 'PFNGLLOADTRANSPOSEMATRIXDPROC'
GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd;
                ^
/usr/local/include/GL/glew.h:15058:17: error: unknown type name 'PFNGLLOADTRANSPOSEMATRIXFPROC'
GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf;
                ^
/usr/local/include/GL/glew.h:15059:17: error: unknown type name 'PFNGLMULTTRANSPOSEMATRIXDPROC'
GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd;
                ^
/usr/local/include/GL/glew.h:15060:17: error: unknown type name 'PFNGLMULTTRANSPOSEMATRIXFPROC'
GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf;
                ^
/usr/local/include/GL/glew.h:15061:17: error: unknown type name 'PFNGLMULTITEXCOORD1DPROC'; did you mean 'PFNGLMULTITEXCOORD4XPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d;
                ^~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD4XPROC
/usr/local/include/GL/glew.h:13827:28: note: 'PFNGLMULTITEXCOORD4XPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4XPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
                           ^
/usr/local/include/GL/glew.h:15062:17: error: unknown type name 'PFNGLMULTITEXCOORD1DVPROC'; did you mean 'PFNGLMULTITEXCOORD1HNVPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv;
                ^~~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD1HNVPROC
/usr/local/include/GL/glew.h:12047:28: note: 'PFNGLMULTITEXCOORD1HNVPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s);
                           ^
/usr/local/include/GL/glew.h:15063:17: error: unknown type name 'PFNGLMULTITEXCOORD1FPROC'; did you mean 'PFNGLMULTITEXCOORD4XPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f;
                ^~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD4XPROC
/usr/local/include/GL/glew.h:13827:28: note: 'PFNGLMULTITEXCOORD4XPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4XPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
                           ^
/usr/local/include/GL/glew.h:15064:17: error: unknown type name 'PFNGLMULTITEXCOORD1FVPROC'; did you mean 'PFNGLMULTITEXCOORD1HNVPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv;
                ^~~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD1HNVPROC
/usr/local/include/GL/glew.h:12047:28: note: 'PFNGLMULTITEXCOORD1HNVPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s);
                           ^
/usr/local/include/GL/glew.h:15065:17: error: unknown type name 'PFNGLMULTITEXCOORD1IPROC'
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i;
                ^
/usr/local/include/GL/glew.h:15066:17: error: unknown type name 'PFNGLMULTITEXCOORD1IVPROC'
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv;
                ^
/usr/local/include/GL/glew.h:15067:17: error: unknown type name 'PFNGLMULTITEXCOORD1SPROC'; did you mean 'PFNGLMULTITEXCOORD4XPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s;
                ^~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD4XPROC
/usr/local/include/GL/glew.h:13827:28: note: 'PFNGLMULTITEXCOORD4XPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4XPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
                           ^
/usr/local/include/GL/glew.h:15068:17: error: unknown type name 'PFNGLMULTITEXCOORD1SVPROC'; did you mean 'PFNGLMULTITEXCOORD1HNVPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv;
                ^~~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD1HNVPROC
/usr/local/include/GL/glew.h:12047:28: note: 'PFNGLMULTITEXCOORD1HNVPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s);
                           ^
/usr/local/include/GL/glew.h:15069:17: error: unknown type name 'PFNGLMULTITEXCOORD2DPROC'; did you mean 'PFNGLMULTITEXCOORD4XPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d;
                ^~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD4XPROC
/usr/local/include/GL/glew.h:13827:28: note: 'PFNGLMULTITEXCOORD4XPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4XPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
                           ^
/usr/local/include/GL/glew.h:15070:17: error: unknown type name 'PFNGLMULTITEXCOORD2DVPROC'; did you mean 'PFNGLMULTITEXCOORD2HNVPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv;
                ^~~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD2HNVPROC
/usr/local/include/GL/glew.h:12049:28: note: 'PFNGLMULTITEXCOORD2HNVPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t);
                           ^
/usr/local/include/GL/glew.h:15071:17: error: unknown type name 'PFNGLMULTITEXCOORD2FPROC'; did you mean 'PFNGLMULTITEXCOORD4XPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f;
                ^~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD4XPROC
/usr/local/include/GL/glew.h:13827:28: note: 'PFNGLMULTITEXCOORD4XPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4XPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
                           ^
/usr/local/include/GL/glew.h:15072:17: error: unknown type name 'PFNGLMULTITEXCOORD2FVPROC'; did you mean 'PFNGLMULTITEXCOORD2HNVPROC'?
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv;
                ^~~~~~~~~~~~~~~~~~~~~~~~~
                PFNGLMULTITEXCOORD2HNVPROC
/usr/local/include/GL/glew.h:12049:28: note: 'PFNGLMULTITEXCOORD2HNVPROC' declared here
typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t);
                           ^
/usr/local/include/GL/glew.h:15073:17: error: unknown type name 'PFNGLMULTITEXCOORD2IPROC'
GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i;
                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

The program itself is very simple, only slightly modified from the GLFW documentation's example code:

#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <stdio.h>

int main(void)
{
    GLFWwindow* window;

    // Initialize the library
    if (!glfwInit())
        return -1;

    // Specify the minimum OpenGL version
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

    // Create a windowed mode window and its OpenGL context
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    // Make the window's context current
    glfwMakeContextCurrent(window);

    printf("GL Version: %s", glGetString(GL_VERSION));

    // Loop until the user closes the window
    while (!glfwWindowShouldClose(window))
    {
        // Render here
        glClear(GL_COLOR_BUFFER_BIT);

        // Swap front and back buffers
        glfwSwapBuffers(window);

        // Poll for and process events
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

Some more details about this project's configuration that may help:

  • GLEW is installed through Homebrew, built from the latest tarball on the project's sourceforge page
  • I've changed a few build settings in the project
    • Always Search User Paths is set to YES
    • User Header Search Paths is set to /usr/local/include
  • The project links against libGLEW.1.10.0.dylib and libglfw.3.0.dylib

If anyone has encountered this before, or otherwise has a solution to this issue I'd very much appreciate it.

Was it helpful?

Solution 2

Like rpowell mentioned above, the way to avoid this error on recent versions of XCode is by doing the following: PS: (I solved this on my project running XCode 8.2.1 and OS X El Capitain 10.11.6):

On the Project tab, select your project by single-clicking on its name (It is the blue icon in my example)

enter image description here

After that, single-click on Build Setting tab and make sure you have the following options selected: All and Combined

enter image description here

Finally, search for 'enable modules' on the search menu, and when it shows Enable Modules(C and Objective-C), just mark no

enter image description here

After that you should be 'hopefully' able to compile your code and get it running.

OTHER TIPS

Alright, some digging around helped me figure out exactly what Clang is complaining about. Looks like the version of Clang that ships with Xcode 5.1 includes support for Modules; which are very cool and interesting and solve a bunch of problems, but also completely break GLEW.

By setting the Enable Modules (C and Objective C) build option to NO, everything works as it did in prior versions and GLEW works as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top