glava
glava copied to clipboard
Building fails with GCC 10
Building on Arch Linux with GCC 10.1.0 fails due to compiler and linker errors.
Following the compilation instructions from README.md, ninja produces the following output before failing: gcc10_build.log
I was able to fix some of these errors by including missing libraries in the corresponding files:
<stdexcept>in glfft_wisdom.cpp<cstdio>and<cerrno>in glfft_gl_interface.hpp<cstdio>in glfft_gl_interface.cpp
Even then, building fails due to linker errors:
/usr/bin/ld: glava@sha/glava_xwin.c.o: in function `glava_abort': xwin.c:(.text+0xf0): multiple definition of `glava_abort'; glava@sha/glava_glava.c.o:glava.c:(.text+0x0): first defined here /usr/bin/ld: glava@sha/glava_xwin.c.o: in function `glava_return': xwin.c:(.text+0x100): multiple definition of `glava_return'; glava@sha/glava_glava.c.o:glava.c:(.text+0x10): first defined here /usr/bin/ld: glava@sha/glava_glx_wcb.c.o: in function `glava_abort': glx_wcb.c:(.text+0x830): multiple definition of `glava_abort'; glava@sha/glava_glava.c.o:glava.c:(.text+0x0): first defined here /usr/bin/ld: glava@sha/glava_glx_wcb.c.o: in function `glava_return': glx_wcb.c:(.text+0x1340): multiple definition of `glava_return'; glava@sha/glava_glava.c.o:glava.c:(.text+0x10): first defined here /usr/bin/ld: glava@sha/glava_render.c.o: in function `glava_abort': render.c:(.text+0x10e0): multiple definition of `glava_abort'; glava@sha/glava_glava.c.o:glava.c:(.text+0x0): first defined here /usr/bin/ld: glava@sha/glava_render.c.o: in function `glava_return': render.c:(.text+0x2510): multiple definition of `glava_return'; glava@sha/glava_glava.c.o:glava.c:(.text+0x10): first defined here /usr/bin/ld: glava@sha/glava_glsl_ext.c.o: in function `glava_abort': glsl_ext.c:(.text+0x80): multiple definition of `glava_abort'; glava@sha/glava_glava.c.o:glava.c:(.text+0x0): first defined here /usr/bin/ld: glava@sha/glava_glsl_ext.c.o: in function `glava_return': glsl_ext.c:(.text+0x1b0): multiple definition of `glava_return'; glava@sha/glava_glava.c.o:glava.c:(.text+0x10): first defined here
None of these errors occured when building with GCC 9.3.0 or when using gcc-8 by manually editing build.ninja.
Same problem here, no idea what the fix is, aside from downgrading compilers.
Im having this issue with ubuntu 20.10, not sure what to set in build.ninja to make it use gcc-8 though
See the changes for -fno-common in the GCC 10 release notes and Porting to GCC 10 page.
The problem is due to all the global variables defined in the glava.h header. Those get defined in every .c file that includes the header, and you get multiple definitions. That's not valid C.
The header should declare them as extern variables, and then there should be a non-extern definition in exactly one .c file.
Or the definitions in the header can be decorated with __attribute__((__common__)) so that multiple definitions are allowed, or just compile everything with -fcommon to use the same behaviour as gcc-9 and earlier (but it will be slightly slower to access those variables).
It's better to just fix the code to be correct C.
There's already a pull request to fix this, somebody just needs to merge it: #185