[Linux] Solar2D compilation errors
OS: Arch Linux x86_64 (Linux 6.17.7-arch1-1) Compiler: clang version 21.1.4
Following the instructions on https://github.com/coronalabs/corona/blob/master/platform/linux/README.md I get errors by the end of the make command:
error: incompatible function pointer types initializing 'size_t (*)(SoundDecoder_Sample *)' (aka 'unsigned long (*)(struct SoundDecoder_Sample *)') with an expression of type 'Uint32 (Sound_Sample *)' (aka 'unsigned int (struct SoundDecoder_Sample *)') [-Wincompatible-function-pointer-types]
Here is an example from corona/external/ALmixer/Isolated/LGPL/wav.c
corona/external/ALmixer/Isolated/LGPL/wav.c:89:5: error: incompatible function pointer types initializing 'size_t (*)(SoundDecoder_Sample *)' (aka 'unsigned long (*)(struct SoundDecoder_Sample *)') with an
expression of type 'uint32_t (Sound_Sample *)' (aka 'unsigned int (struct SoundDecoder_Sample *)') [-Wincompatible-function-pointer-types]
89 | WAV_read, /* read() method */
| ^~~~~~~~
corona/external/ALmixer/Isolated/LGPL/wav.c:91:5: error: incompatible function pointer types initializing 'int (*)(SoundDecoder_Sample *, size_t)' (aka 'int (*)(struct SoundDecoder_Sample *, unsigned long)') with
an expression of type 'int (Sound_Sample *, uint32_t)' (aka 'int (struct SoundDecoder_Sample *, unsigned int)') [-Wincompatible-function-pointer-types]
91 | WAV_seek /* seek() method */
| ^~~~~~~~
Is there a way to fix it or disable enforcing the warning -Wincompatible-function-pointer-types as an error?
There's a type mismatch on this target, apparently... in wav.c, there's a list up top:
static int WAV_init(void);
static void WAV_quit(void);
static int WAV_open(Sound_Sample *sample, const char *ext);
static void WAV_close(Sound_Sample *sample);
static uint32_t WAV_read(Sound_Sample *sample);
static int WAV_rewind(Sound_Sample *sample);
static int WAV_seek(Sound_Sample *sample, uint32_t ms);
Presumably, you want to change those two uint32_t instances to size_t. Then do the same thing in the implemented functions, further down in that same file.
Thanks that worked! I'm now working through the implicit function declaration errors.
I wonder if https://github.com/coronalabs/corona/blob/master/external/mpg123-1.13.1/src/libmpg123/compat.h mistakenly used a few ifdef in place of ifndef. The implicit function declaration errors were resolved (so far) by switching ifdef->ifndef for:
- https://github.com/coronalabs/corona/blob/f09b81447900f8e89cb8a7eb5a0db7dc5762f691/external/mpg123-1.13.1/src/libmpg123/compat.h#L20
- https://github.com/coronalabs/corona/blob/f09b81447900f8e89cb8a7eb5a0db7dc5762f691/external/mpg123-1.13.1/src/libmpg123/compat.h#L36
- https://github.com/coronalabs/corona/blob/f09b81447900f8e89cb8a7eb5a0db7dc5762f691/external/mpg123-1.13.1/src/libmpg123/compat.h#L63
I'm not going to switch anymore defs, I don't know how to validate which is the right choice since I'm not too good with C/C++.
Now stuck at this linking error:
[ 39%] Linking CXX executable Solar2DSimulator
clang++: error: unknown argument: '-export-dynamic'
make[2]: *** [CMakeFiles/Solar2DSimulator.dir/build.make:9589: Solar2DSimulator] Error 1
make[1]: *** [CMakeFiles/Makefile2:808: CMakeFiles/Solar2DSimulator.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 39%] Linking CXX executable Solar2D
clang++: error: unknown argument: '-export-dynamic'
make[2]: *** [CMakeFiles/Solar2D.dir/build.make:9589: Solar2D] Error 1
make[1]: *** [CMakeFiles/Makefile2:472: CMakeFiles/Solar2D.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Turns out the linker error is because of clang's linker not playing well with -export-dynamic, so I switched to gcc.
Fixed a few more incompatible pointer types and now Solar2D completes the build and runs fine:
I don't know why the console is not showing any text though: