Opendigitalradio / dablin

DAB/DAB+ receiver for Linux (including ETI-NI and EDI AF playback)
GNU General Public License v3.0
123 stars 27 forks source link

MacOS build fails for an error in SDL2 #68

Closed ale-rinaldi closed 3 years ago

ale-rinaldi commented 3 years ago

Hello,

I had an hard time compiling dablin on MacOS Monterey, 12.0.1 (21A559). I followed the instructions in the README, installing the dependencies with Homebrew, but I kept getting this error:

$ make
[  2%] Building C object fec/CMakeFiles/fec.dir/encode_rs_char.c.o
[  4%] Building C object fec/CMakeFiles/fec.dir/decode_rs_char.c.o
[  7%] Building C object fec/CMakeFiles/fec.dir/init_rs_char.c.o
[  9%] Linking C static library libfec.a
[  9%] Built target fec
[ 12%] Building C object fec/test/CMakeFiles/rstest.dir/rstest.c.o
[ 14%] Linking C executable rstest
[ 14%] Built target rstest
[ 17%] Building C object fec/test/CMakeFiles/rs_speedtest.dir/rs_speedtest.c.o
[ 19%] Linking C executable rs_speedtest
[ 19%] Built target rs_speedtest
[ 21%] Building CXX object src/CMakeFiles/dablin_gtk.dir/sdl_output.cpp.o
In file included from /Users/alerinaldi/dablin/src/sdl_output.cpp:19:
In file included from /Users/alerinaldi/dablin/src/sdl_output.h:29:
In file included from /usr/local/include/SDL2/SDL.h:32:
In file included from /usr/local/include/SDL2/SDL_main.h:25:
/usr/local/include/SDL2/SDL_stdinc.h:476:5: error: use of undeclared identifier 'memset_pattern4'
    memset_pattern4(dst, &val, dwords * 4);
    ^
1 error generated.
make[2]: *** [src/CMakeFiles/dablin_gtk.dir/sdl_output.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/dablin_gtk.dir/all] Error 2
make: *** [all] Error 2

Since this seems more a SDL2 issue, I searched for similar issues but I found only https://github.com/dingusdev/dingusppc/issues/15 that seems to be no longer applying.

Eventually, I edited the /usr/local/include/SDL2/SDL_stdinc.h removing lines 464 and 465 and replacing line 466 (now 464) with:

#if defined(__GNUC__) && defined(__i386__)

Doing this, it built without any other issue and it actually works, but I really believe this is not the most correct approach :)

basicmaster commented 3 years ago

Indeed, there should be a better solution :-)

So in the end, you just reverted this commit to make it work, it seems.

Could you check whether this hint fixes the problem? I.e. return to the original, unmodified SDL2 headers and instead modify sdl_output.h to move #include "SDL.h" from line 29 above all other includes, to line 21? Maybe the C header that are included by SDL (and DABlin, too) need other definitions to be set, before they are included....in order to get memset_pattern4 available.

Unfortunately I don't have a MacOS system to test it myself. The MacOS instructions came from @npm-sdr who maybe has stumbled upon this issue himself...

ale-rinaldi commented 3 years ago

Yep, you were right, that was the point. I actually came across that same comment before opening the issue, but for some reason I didn't give importance to it.

I moved the SDL import at the top both in sdl_output.h and in the files that, directly or indirectly, included it, and now it builds correctly. I opened a PR for it.

Thanks for your help :)

basicmaster commented 3 years ago

Great, thank you; I just merged your PR!