Kivy: Kivy doesn't compile with SDL_mixer v2.0.2

Created on 27 Oct 2017  Â·  14Comments  Â·  Source: kivy/kivy

Versions

  • Python: 3.6.2
  • OS: ArchLinux
  • Kivy: Latest master branch as of 2017.10.27
  • Kivy installation method: Compiling from source

Description

Kivy fails to compile with the error listed below. The reason is that some flags were removed/renamed in SDL2_mixer release 2.0.2, specifically MIX_INIT_MODPLUG and MIX_INIT_FLUIDSYNTH were removed from SDL_mixer.h.

I'm willing to take a crack at a fix, but presumably we want to maintain backwards compatibility, so my thought is to redefine these flags locally if they don't exist in the header.

Code and Logs

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=armv8-a -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -march=armv8-a -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -march=armv8-a -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -Ikivy/include -I/usr/include/SDL2 -I/usr/local/include/SDL2 -I/usr/include/SDL2 -I/usr/include/SDL2 -I/usr/include/python3.6m -c kivy/core/audio/audio_sdl2.c -o build/temp.linux-aarch64-3.6/kivy/core/audio/audio_sdl2.o
kivy/core/audio/audio_sdl2.c: In function '__pyx_f_4kivy_4core_5audio_10audio_sdl2_mix_init':
kivy/core/audio/audio_sdl2.c:1647:63: error: 'MIX_INIT_MODPLUG' undeclared (first use in this function); did you mean 'MIX_INIT_MOD'?
   __pyx_v_want_flags = (__pyx_v_want_flags | ((MIX_INIT_MOD | MIX_INIT_MODPLUG) | MIX_INIT_FLUIDSYNTH));
                                                               ^~~~~~~~~~~~~~~~
                                                               MIX_INIT_MOD
kivy/core/audio/audio_sdl2.c:1647:63: note: each undeclared identifier is reported only once for each function it appears in
kivy/core/audio/audio_sdl2.c:1647:83: error: 'MIX_INIT_FLUIDSYNTH' undeclared (first use in this function); did you mean 'MIX_INIT_MID'?
   __pyx_v_want_flags = (__pyx_v_want_flags | ((MIX_INIT_MOD | MIX_INIT_MODPLUG) | MIX_INIT_FLUIDSYNTH));
                                                                                   ^~~~~~~~~~~~~~~~~~~
                                                                                   MIX_INIT_MID
kivy/core/audio/audio_sdl2.c: In function '__pyx_pf_4kivy_4core_5audio_10audio_sdl2_9MusicSDL2_extensions':
kivy/core/audio/audio_sdl2.c:4936:69: error: 'MIX_INIT_MODPLUG' undeclared (first use in this function); did you mean 'MIX_INIT_MOD'?
   __pyx_t_2 = ((__pyx_v_4kivy_4core_5audio_10audio_sdl2_mix_flags & MIX_INIT_MODPLUG) != 0);
                                                                     ^~~~~~~~~~~~~~~~
                                                                     MIX_INIT_MOD
 error: command 'gcc' failed with exit status 1

Most helpful comment

This still exists on MacOS High Sierra

All 14 comments

This is the new definition in SDL_mixer.h in v2.0.2:

typedef enum
{
    MIX_INIT_FLAC   = 0x00000001,
    MIX_INIT_MOD    = 0x00000002,
    MIX_INIT_MP3    = 0x00000008,
    MIX_INIT_OGG    = 0x00000010,
    MIX_INIT_MID    = 0x00000020
} MIX_InitFlags;

And the prior one for comparison:

typedef enum
{
    MIX_INIT_FLAC        = 0x00000001,
    MIX_INIT_MOD         = 0x00000002,
    MIX_INIT_MODPLUG     = 0x00000004,
    MIX_INIT_MP3         = 0x00000008,
    MIX_INIT_OGG         = 0x00000010,
    MIX_INIT_FLUIDSYNTH  = 0x00000020
} MIX_InitFlags;

I'm 100% sure nobody use fluidsynth. If you provide a patch directly, we'll merge it.

Where do you enter in the new definitions? Please bare with me. I am new to this.

Looks like someone took a crack at a fix here: https://github.com/kivy/kivy/pull/5459

The ArchLinux Kivy package somehow manages to get around this compilation issue:

The python-kivy 1.10.0 package depends on sdl2_mixer 2.0.2 and it works without the patch mentioned.

I was trying to install Kivy in a Python 3 virtual environment with a requirements.txt file containing:
Cython==0.25.2
Kivy==1.10.0
and failed with the same error: ‘MIX_INIT_MODPLUG’ undeclared (first use in this function); did you mean ‘MIX_INIT_MOD’? error

After installing the package from the repository: sudo pacman -S python-kivy and adding the path to the global Python installation where Kivy was installed to:
PYTHONPATH=/usr/lib/python3.6/site-packages/:/usr/local/lib/python3.6/site-packages/ python3 main.py , Kivy module gets loaded successfully.

That's interesting. Unfortunately I need to compile the latest master branch because I'm running Arch on a Raspberry Pi, and if I use the 1.10.0 version from the repository performance is dreadful.

Indeed, building a python-kivy Arch package from master branch, via makepkg -s && makepkg --skipinteg, fails with the same error.

Applying the the patch to the PKGBUILD works for building master Kivy on x86_64 desktop

Building for ARM should work the same as for the desktop, just need to update the respective PKGBUILD file:
https://archlinuxarm.org/packages/arm/python-kivy
https://archlinuxarm.org/packages/arm/sdl_mixer

Replace 'arm' in the URL with the ARM version of the Raspberry Pi you have:

Raspberry Pi 1 - armv6
Raspberry Pi 2 - armv7
Raspberry Pi 3 - armv8

However, I see that the package for sdl_mixer in ArchLinux for ARM is 1.2.12-5 , would need to update that as well.

Closed by #5459

This still exists on MacOS High Sierra

@duaneking
If you install development version like pip install https://github.com/kivy/kivy/archive/master.zip (see https://kivy.org/docs/installation/installation-osx.html) then it works on High Sierra.

Not an option for me; I'm looking for non-kiva options now since HS has been around long enough that if the community doesn't care to ship/maintain this, then I shouldn't let myself depend on it.

Is there any change that you could release a Kivy version with this fix? Since Ubuntu 18.04 just got released this will affect practically 95% of our Linux user base.

installing Kivy Development Version worked on High Sierra. Thanks fantastechit!

Was this page helpful?
0 / 5 - 0 ratings