orangeduck / Corange

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

MinGW Compilation: "redeclared as different kind of symbol" errors #66

Closed choretortle closed 3 years ago

choretortle commented 3 years ago

I'm not experienced at C command line compilation; compiling for Windows, attempted from both Windows MSys2 and Linux platforms with same error. Only change to code was the CC and AR variables in Makefile. I'm not sure if the problem is me, or that I'm the only one compiling this way:

CC=x86_64-w64-mingw32-gcc-8.3-posix
AR=x86_64-w64-mingw32-gcc-ar-posix

I downloaded the mingw SDL, SDL_mixer, SDL_net libraries and just copied the headers into the .include/SDL2 folder manually This is the "make" result:

make
x86_64-w64-mingw32-gcc-8.3-posix src/cengine.c -c -I ./include -std=gnu99 -Wall -Werror -Wno-unused -O3 -g -fPIC -o obj/cengine.o
In file included from ./include/cengine.h:34,
                 from src/cengine.c:1:
./include/SDL2/SDL_local.h:116:28: error: ‘glActiveTexture’ redeclared as different kind of symbol
   extern GLACTIVETEXTUREFN glActiveTexture;
                            ^~~~~~~~~~~~~~~
In file included from ./include/cengine.h:30,
                 from src/cengine.c:1:
./include/SDL2/SDL_opengl.h:1878:23: note: previous declaration of ‘glActiveTexture’ was here
 GLAPI void GLAPIENTRY glActiveTexture( GLenum texture );
                       ^~~~~~~~~~~~~~~
In file included from ./include/cengine.h:34,
                 from src/cengine.c:1:
./include/SDL2/SDL_local.h:117:35: error: ‘glCompressedTexImage2D’ redeclared as different kind of symbol
   extern GLCOMPRESSEDTEXIMAGE2DFN glCompressedTexImage2D;
                                   ^~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/cengine.h:30,
                 from src/cengine.c:1:
./include/SDL2/SDL_opengl.h:1884:23: note: previous declaration of ‘glCompressedTexImage2D’ was here
 GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data );
                       ^~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/cengine.h:34,
                 from src/cengine.c:1:
./include/SDL2/SDL_local.h:118:25: error: ‘glTexImage3D’ redeclared as different kind of symbol
   extern GLTEXIMAGE3DFN glTexImage3D;
                         ^~~~~~~~~~~~
In file included from ./include/cengine.h:30,
                 from src/cengine.c:1:
./include/SDL2/SDL_opengl.h:1551:23: note: previous declaration of ‘glTexImage3D’ was here
 GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level,
                       ^~~~~~~~~~~~
make: *** [Makefile:43: obj/cengine.o] Error 1
blogdron commented 3 years ago

this https://github.com/orangeduck/Corange/blob/master/include/SDL2/SDL_local.h#L115

comment this


-#if !defined(__unix__) && !defined(__APPLE__)
-  extern GLACTIVETEXTUREFN glActiveTexture;
-  extern GLCOMPRESSEDTEXIMAGE2DFN glCompressedTexImage2D;
-  extern GLTEXIMAGE3DFN glTexImage3D;
-#endif

+//#if !defined(__unix__) && !defined(__APPLE__)
+//extern GLACTIVETEXTUREFN glActiveTexture;
+//extern GLCOMPRESSEDTEXIMAGE2DFN glCompressedTexImage2D;
+//extern GLTEXIMAGE3DFN glTexImage3D;
+//#endif

And compile. In fact, here you need to solve by adding a check, but for your case this block is not needed.

Or maybe for example

- !defined(__unix__) && !defined(__APPLE__)
+ !defined(__unix__) && !defined(__APPLE__) && !defined(__MSYSMINGW__)

and CC=x86_64-w64-mingw32-gcc-8.3-posix -D__MSYSMINGW__

I do not remember which definition defines exactly what we are working with MSys2. You just need to check or del code. Sorry for my english

choretortle commented 3 years ago

Thank you, fedor-elizarov ! That's definitely the issue 👍 I can move forward with ironing it out.