Closed dickensas closed 3 years ago
thanks for the immediate response
I modified both the .h file and .c file
but now I am getting new error
src/SDL2/SDL_local.c: In function 'SDL_GL_LoadExtensions':
src/SDL2/SDL_local.c:309:6: error: lvalue required as left operand of assignment
309 | name = (type)SDL_GL_GetProcAddress(#name); \
| ^
src/SDL2/SDL_local.c:369:3: note: in expansion of macro 'SDL_GL_LoadExtension'
369 | SDL_GL_LoadExtension(GLACTIVETEXTUREFN, glActiveTexture);
| ^~~~~~~~~~~~~~~~~~~~
src/SDL2/SDL_local.c:312:8: error: lvalue required as left operand of assignment
312 | name = (type)SDL_GL_GetProcAddress(#name"EXT"); \
| ^
src/SDL2/SDL_local.c:369:3: note: in expansion of macro 'SDL_GL_LoadExtension'
369 | SDL_GL_LoadExtension(GLACTIVETEXTUREFN, glActiveTexture);
| ^~~~~~~~~~~~~~~~~~~~
src/SDL2/SDL_local.c:316:8: error: lvalue required as left operand of assignment
316 | name = (type)SDL_GL_GetProcAddress(#name"ARB"); \
| ^
src/SDL2/SDL_local.c:369:3: note: in expansion of macro 'SDL_GL_LoadExtension'
369 | SDL_GL_LoadExtension(GLACTIVETEXTUREFN, glActiveTexture);
| ^~~~~~~~~~~~~~~~~~~~
src/SDL2/SDL_local.c:309:6: error: lvalue required as left operand of assignment
309 | name = (type)SDL_GL_GetProcAddress(#name); \
| ^
src/SDL2/SDL_local.c:370:3: note: in expansion of macro 'SDL_GL_LoadExtension'
370 | SDL_GL_LoadExtension(GLCOMPRESSEDTEXIMAGE2DFN, glCompressedTexImage2D);
| ^~~~~~~~~~~~~~~~~~~~
src/SDL2/SDL_local.c:312:8: error: lvalue required as left operand of assignment
312 | name = (type)SDL_GL_GetProcAddress(#name"EXT"); \
| ^
src/SDL2/SDL_local.c:370:3: note: in expansion of macro 'SDL_GL_LoadExtension'
370 | SDL_GL_LoadExtension(GLCOMPRESSEDTEXIMAGE2DFN, glCompressedTexImage2D);
| ^~~~~~~~~~~~~~~~~~~~
src/SDL2/SDL_local.c:316:8: error: lvalue required as left operand of assignment
316 | name = (type)SDL_GL_GetProcAddress(#name"ARB"); \
| ^
src/SDL2/SDL_local.c:370:3: note: in expansion of macro 'SDL_GL_LoadExtension'
370 | SDL_GL_LoadExtension(GLCOMPRESSEDTEXIMAGE2DFN, glCompressedTexImage2D);
| ^~~~~~~~~~~~~~~~~~~~
src/SDL2/SDL_local.c:309:6: error: lvalue required as left operand of assignment
309 | name = (type)SDL_GL_GetProcAddress(#name); \
| ^
src/SDL2/SDL_local.c:371:3: note: in expansion of macro 'SDL_GL_LoadExtension'
371 | SDL_GL_LoadExtension(GLTEXIMAGE3DFN, glTexImage3D);
| ^~~~~~~~~~~~~~~~~~~~
src/SDL2/SDL_local.c:312:8: error: lvalue required as left operand of assignment
312 | name = (type)SDL_GL_GetProcAddress(#name"EXT"); \
| ^
src/SDL2/SDL_local.c:371:3: note: in expansion of macro 'SDL_GL_LoadExtension'
371 | SDL_GL_LoadExtension(GLTEXIMAGE3DFN, glTexImage3D);
| ^~~~~~~~~~~~~~~~~~~~
src/SDL2/SDL_local.c:316:8: error: lvalue required as left operand of assignment
316 | name = (type)SDL_GL_GetProcAddress(#name"ARB"); \
| ^
src/SDL2/SDL_local.c:371:3: note: in expansion of macro 'SDL_GL_LoadExtension'
371 | SDL_GL_LoadExtension(GLTEXIMAGE3DFN, glTexImage3D);
| ^~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:46: obj/SDL_local.o] Error 1
comment out this code
/*
#if !defined(__unix__) && !defined(__APPLE__)
SDL_GL_LoadExtension(GLACTIVETEXTUREFN, glActiveTexture);
SDL_GL_LoadExtension(GLCOMPRESSEDTEXIMAGE2DFN, glCompressedTexImage2D);
SDL_GL_LoadExtension(GLTEXIMAGE3DFN, glTexImage3D);
#endif
*/
and recompile ^.^
But after all this, there may be problems if you compile for linux (but may be not :D ). There you just need to make a normal definition for which platform we are building and what, taking into account cross-compilation, simply by adding something like !defined (__MSYSMINGW __)
or something like that. And all will be well. I am not able to debug for all assembly options with correct macros, so that it would simply be assembled without these comments in all cases. I hope someone will work it out (or myself if time appears)
I already did, but it seems it is coming from #define
at line 308 in SDL_local.c
The macro is too long
I tried to fix it it is again going to another error in linking
Error 1
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/shader.o: in function `shader_program_disable':
C:\msys64\home\das2\Corange/src/assets/shader.c:200: undefined reference to `__imp_glActiveTexture'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/shader.o: in function `shader_program_set_texture':
C:\msys64\home\das2\Corange/src/assets/shader.c:273: undefined reference to `__imp_glActiveTexture'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/shader.o: in function `shader_program_set_texture_id':
C:\msys64\home\das2\Corange/src/assets/shader.c:286: undefined reference to `__imp_glActiveTexture'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/texture.o: in function `lut_load_file':
C:\msys64\home\das2\Corange/src/assets/texture.c:229: undefined reference to `__imp_glTexImage3D'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/texture.o: in function `dds_load_file':
C:\msys64\home\das2\Corange/src/assets/texture.c:506: undefined reference to `__imp_glCompressedTexImage2D'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/texture.o: in function `acv_load_file':
C:\msys64\home\das2\Corange/src/assets/texture.c:617: undefined reference to `__imp_glTexImage3D'
Error 2
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/ui_toast.o:C:\msys64\home\das2\Corange/./include/cengine.h:80: multiple definition of `warning_str'; obj/casset.o:C:\msys64\home\das2\Corange/./include/cengine.h:80: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/ui_toast.o:C:\msys64\home\das2\Corange/./include/cengine.h:79: multiple definition of `warning_buf'; obj/casset.o:C:\msys64\home\das2\Corange/./include/cengine.h:79: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/ui_toast.o:C:\msys64\home\das2\Corange/./include/cengine.h:83: multiple definition of `debug_str'; obj/casset.o:C:\msys64\home\das2\Corange/./include/cengine.h:83: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/ui_toast.o:C:\msys64\home\das2\Corange/./include/cengine.h:82: multiple definition of `debug_buf'; obj/casset.o:C:\msys64\home\das2\Corange/./include/cengine.h:82: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/ui_toast.o:C:\msys64\home\das2\Corange/./include/cengine.h:76: multiple definition of `error_str'; obj/casset.o:C:\msys64\home\das2\Corange/./include/cengine.h:76: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/ui_toast.o:C:\msys64\home\das2\Corange/./include/cengine.h:73: multiple definition of `error_buf'; obj/casset.o:C:\msys64\home\das2\Corange/./include/cengine.h:73: first defined here
and so on
I can fix it with my experience either I will fixit, if I have time, or someone will fix it
you gcc version? try gcc-9 (last errors specific for gcc-10 migration need ignore default options -fno-common to -fcommon)
Thanks, the first issue is fixed , -fcommon is working but, it says
undefined reference to `__imp_glActiveTexture'
undefined reference to `__imp_glTexImage3D'
undefined reference to `__imp_glTexImage3D'
in shader.c
and texture.c
These symbols are not in the mingw libraries, but they are probably in gl.dll (or whatever?) Which is already available on windows or wine
I use custom openGL handlers for all opengl funtions, Thus, all the necessary functions are external and are loaded at runtime and when assembling, their mobets will not be at all.
in SDL_local.h
typedef void( APIENTRY* GLACTIVETEXTUREFN)( GLenum texture );
typedef void( APIENTRY *GLTEXIMAGE3DFN)( GLenum target, GLint level,GLint internalFormat,GLsizei width, GLsizei height,GLsizei depth, GLint border,GLenum format, GLenum type,const GLvoid *pixels );
extern GLACTIVETEXTUREFN glActiveTexture;·
extern GLTEXIMAGE3DFN glTexImage3D;
in SDL_local.c
GLTEXIMAGE3DFN glTexImage3D = NULL;
SDL_GL_LoadExtension( GLTEXIMAGE3DFN, glTexImage3D);
GLACTIVETEXTUREFN glActiveTexture = NULL;
SDL_GL_LoadExtension( GLACTIVETEXTUREFN, glActiveTexture);
This should fix the problem, solve the other functions in the same way. Here we are talking. Yes, now we do not have information about these functions, but we know that we will get them on our own.
The reason is that we already commented those code, which is our primary concern of this open issue
Which is
./include/SDL2/SDL_local.h:116:28: error: 'glActiveTexture' redeclared as different kind of symbol
116 | extern GLACTIVETEXTUREFN glActiveTexture;
| ^~~~~~~~~~~~~~~
In file included from ./include/cengine.h:30,
from ./include/casset.h:24,
from src/casset.c:1:
I did solve this issue by making a small workaround, with a different symbol name for the function pointer
Existing code
extern GLACTIVETEXTUREFN glActiveTexture;·
extern GLTEXIMAGE3DFN glTexImage3D;
My code -- I add g_
in front of it
extern GLACTIVETEXTUREFN g_glActiveTexture;·
extern GLTEXIMAGE3DFN g_glTexImage3D;
I wrote a small function for getting substring -- which is not really required
void substr(char s[], char sub[], int p, int l) {
int c = 0;
while (c < l) {
sub[c] = s[p+c-1];
c++;
}
sub[c] = '\0';
}
And I wrote an additional macro by duplicated the existing code
#define gl_SDL_GL_LoadExtension(type, name) \
char gName##name[100]; \
char gNameEXT##name[100]; \
char gNameARB##name[100]; \
substr(#name, gName##name, 3, strlen(#name)); \
substr(#name, gNameEXT##name, 3, strlen(#name)); \
substr(#name, gNameARB##name, 3, strlen(#name)); \
strcat(gNameEXT##name, "EXT"); \
strcat(gNameARB##name, "ARB"); \
name = (type)SDL_GL_GetProcAddress(gName##name); \
if (name == NULL) { \
fprintf(stderr, "Failed to load function '%s', looking for function '%s'...\n", gName##name, gNameEXT##name); \
name = (type)SDL_GL_GetProcAddress(gNameEXT##name); \
} \
if (name == NULL) { \
fprintf(stderr, "Failed to load function '%s', looking for function '%s'...\n", gNameEXT##name, gNameARB##name); \
name = (type)SDL_GL_GetProcAddress(gNameARB##name); \
} \
if (name == NULL) { fprintf(stderr, "Completely failed to load OpenGL extension function '%s'. Use of this function will crash\n", gName##name); }
this actually registers the opengl from the SDL2 as below
g_glActiveTexture = (GLACTIVETEXTUREFN)SDL_GL_GetProcAddress("glActiveTexture")
and in the C code, instead of calling glActiveTexture
I call g_glActiveTexture
which means the code texture.c
and shader.c
is changed to use the new function with g_
Then I ran the teapot demo I got the output without any error
g_
For the first time I see what is needed, it is some kind of specificity. I have nothing to say here. I'm doing cross-compilation via mingw64 without MSYS on linux (Debian) and don't use any special prefixes. Everything is working.
The first problem was that there were ads above in the headlines. Then we removed it, but in the mingw libraries there were no symbols that we requested from this, a second error appeared and then we said we will have such functions and we do not have external symbols for them, but we will get them from another external library which currently unavailable. Everything. The fact that you have to add a prefix ... This (for me) is very strange, although I may not have encountered this with me only Linux and the usual mingw64
In any case, the problem is solved, we figured it out and that's good. And what we now know about the strange prefix will be useful to many. I would be confused if I needed such functions =)
Since the only thing I have never used is MSYS2, it is probably its peculiarity. I'm sure your macros will come in handy, thanks for sharing.
We can put corange_
if we want :)
Few libraries uses a different variable name
Some Example
gleswActiveTexture = (PFNGLACTIVETEXTUREPROC)proc("glActiveTexture");
gl3wActiveTexture = (PFNGLACTIVETEXTUREPROC)proc("glActiveTexture");
__glewActiveTexture
Aaaaa, everything. Got it. I'm a fool... )))))))
I have installed SDL2 in latest version of MSYS2
And I have issue the
make
commandI am getting the below error
What could be the issue