orangeduck / Corange

Pure C Game Engine
http://www.youtube.com/watch?v=482GxqTWXtA
Other
1.79k stars 199 forks source link

Attempted to build on OS X: Lots of OpenGL redefinitions #15

Closed charles-l closed 9 years ago

charles-l commented 9 years ago

Here's the output (built with clang in this case, but same errors with gcc-4.9):

gcc src/casset.c -c -I ./include -std=gnu99 -Wall -Werror -Wno-unused -O3 -g -fPIC -o obj/casset.o
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:116:28: error: redefinition of 'glActiveTexture' as
      different kind of symbol
  extern GLACTIVETEXTUREFN glActiveTexture;
                           ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2769:13: note:
      previous definition is here
extern void glActiveTexture (GLenum texture);
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:117:35: error: redefinition of
      'glCompressedTexImage2D' as different kind of symbol
  extern GLCOMPRESSEDTEXIMAGE2DFN glCompressedTexImage2D;
                                  ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2762:13: note:
      previous definition is here
extern void glCompressedTexImage2D (GLenum target, GLint level, GLenum i...
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:118:25: error: redefinition of 'glTexImage3D' as
      different kind of symbol
  extern GLTEXIMAGE3DFN glTexImage3D;
                        ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2717:13: note:
      previous definition is here
extern void glTexImage3D (GLenum target, GLint level, GLint internalform...
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:120:25: error: redefinition of 'glCreateShader' as
      different kind of symbol
extern GLCREATESHADERFN glCreateShader;
                        ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2922:15: note:
      previous definition is here
extern GLuint glCreateShader (GLenum type);
              ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:121:26: error: redefinition of 'glCreateProgram' as
      different kind of symbol
extern GLCREATEPROGRAMFN glCreateProgram;
                         ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2925:15: note:
      previous definition is here
extern GLuint glCreateProgram (void);
              ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:122:25: error: redefinition of 'glShaderSource' as
      different kind of symbol
extern GLSHADERSOURCEFN glShaderSource;
                        ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2923:13: note:
      previous definition is here
extern void glShaderSource (GLuint shader, GLsizei count, const GLchar* ...
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:123:26: error: redefinition of 'glCompileShader' as
      different kind of symbol
extern GLCOMPILESHADERFN glCompileShader;
                         ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2924:13: note:
      previous definition is here
extern void glCompileShader (GLuint shader);
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:124:29: error: redefinition of 'glGetShaderInfoLog'
      as different kind of symbol
extern GLGETSHADERINFOLOGFN glGetShaderInfoLog;
                            ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2955:13: note:
      previous definition is here
extern void glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei ...
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:125:25: error: redefinition of 'glAttachShader' as
      different kind of symbol
extern GLATTACHSHADERFN glAttachShader;
                        ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2926:13: note:
      previous definition is here
extern void glAttachShader (GLuint program, GLuint shader);
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:126:24: error: redefinition of 'glLinkProgram' as
      different kind of symbol
extern GLLINKPROGRAMFN glLinkProgram;
                       ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2927:13: note:
      previous definition is here
extern void glLinkProgram (GLuint program);
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:127:30: error: redefinition of 'glGetProgramInfoLog'
      as different kind of symbol
extern GLGETPROGRAMINFOLOGFN glGetProgramInfoLog;
                             ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2956:13: note:
      previous definition is here
extern void glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsize...
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:128:22: error: redefinition of 'glIsProgram' as
      different kind of symbol
extern GLISPROGRAMFN glIsProgram;
                     ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2951:18: note:
      previous definition is here
extern GLboolean glIsProgram (GLuint program);
                 ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:129:21: error: redefinition of 'glIsShader' as
      different kind of symbol
extern GLISSHADERFN glIsShader;
                    ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2950:18: note:
      previous definition is here
extern GLboolean glIsShader (GLuint shader);
                 ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:130:31: error: redefinition of 'glGetAttachedShaders'
      as different kind of symbol
extern GLGETATTACHEDSHADERSFN glGetAttachedShaders;
                              ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2954:13: note:
      previous definition is here
extern void glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsi...
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:131:31: error: redefinition of 'glGetUniformLocation'
      as different kind of symbol
extern GLGETUNIFORMLOCATIONFN glGetUniformLocation;
                              ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2957:14: note:
      previous definition is here
extern GLint glGetUniformLocation (GLuint program, const GLchar *name);
             ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:132:22: error: redefinition of 'glUniform1f' as
      different kind of symbol
extern GLUNIFORM1FFN glUniform1f;
                     ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2931:13: note:
      previous definition is here
extern void glUniform1f (GLint location, GLfloat v0);
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:133:22: error: redefinition of 'glUniform1i' as
      different kind of symbol
extern GLUNIFORM1IFN glUniform1i;
                     ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2935:13: note:
      previous definition is here
extern void glUniform1i (GLint location, GLint v0);
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:134:25: error: redefinition of 'glDeleteShader' as
      different kind of symbol
extern GLDELETESHADERFN glDeleteShader;
                        ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2920:13: note:
      previous definition is here
extern void glDeleteShader (GLuint shader);
            ^
In file included from src/casset.c:1:
In file included from ./include/casset.h:24:
In file included from ./include/cengine.h:34:
./include/SDL2/SDL_local.h:135:26: error: redefinition of 'glDeleteProgram' as
      different kind of symbol
extern GLDELETEPROGRAMFN glDeleteProgram;
                         ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2929:13: note:
      previous definition is here
extern void glDeleteProgram (GLuint program);
            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [obj/casset.o] Error 1

Should I be linking with a different library or do I manually have to go and redefine all the functions?

orangeduck commented 9 years ago

Hey,

Other people have had this issue too. Using OpenGL with extensions has become a nightmare partially because Apple keep pushing the standards forward and (for example) including many of the extension functions in their headers which on a lot of older systems these headers don't exist. This is why I have to do all this setup in SDL_local to add them to the project manually. This is conflicting with the headers Apple added.

I don't think there is an easy fix - and unfortunately I'm too busy to work on Corange at the moment but I know there is a fork by Greg Copeland who said he managed to fix this error:

https://github.com/gtco/Corange

I hope that can help,

charles-l commented 9 years ago

@orangeduck with a little fiddling that fork worked, thanks!