Bug#951087: Bug#952049: pekka-kana-2: FTBFS: SDL_image.h:100:24: error: missing binary operator before token "("

Simon McVittie smcv at debian.org
Sun Feb 23 19:06:42 GMT 2020


On Sun, 23 Feb 2020 at 08:56:19 +0100, Lucas Nussbaum wrote:
> During a rebuild of all packages in sid, your package failed to build
> on amd64.
> 
> > In file included from src/draw.cpp:19:
> > /usr/include/SDL2/SDL_image.h:100:24: error: missing binary operator before token "("
> >   100 | #if SDL_VERSION_ATLEAST(2,0,0)

Many games make wrong-but-usually-true assumptions about where the SDL2
headers and libraries can be found, and how they relate to each other.
pekka-kana-2 seems to have these assumptions:

- Assumes that $(pkg-config --cflags sdl2) and $(pkg-config --libs sdl2)
  are also going to be enough to find SDL2_mixer headers and -lSDL2_mixer,
  similar to the neverball issue mentioned in
  <https://bugs.debian.org/909740> and addressed in
  <https://salsa.debian.org/sdl-team/libsdl2/commit/6f58f10282cf9b9af567ec520f0d2c4dc368dbea>

- Assumes that SDL2 and SDL2_foo headers can be #included as <SDL2/*.h>,
  similar to <https://bugs.debian.org/952066>,
  <https://bugs.debian.org/952046> and <https://bugs.debian.org/952098>
  (this is not portable, and instead they are meant to be included as
  #include <SDL.h> and #include <SDL_mixer.h>, which is portable)

- Some weirdness in src/draw.cpp where it includes <SDL2/SDL_image.h>
  but doesn't link to -lSDL2_image, which I currently don't fully understand
  (perhaps src/draw.cpp really only needs the base SDL2 library, and not
  SDL2_image?)

Despite not being considered correct, pekka-kana-2's assumptions used to
work before we modified SDL2 to be multiarch co-installable
(<https://bugs.debian.org/909740>). There are two ways to address this
bug:

- Fix pekka-kana-2 to stop making these assumptions, and instead use SDL
  with the recommended patterns:
    - PKG_CONFIG ?= pkg-config
      (so that cross-compilation uses the correct cross-pkg-config)
    - add $(${PKG_CONFIG} --cflags sdl2) to all C/C++ compiler command-lines
    - add $(${PKG_CONFIG} --libs sdl2) to linker command-line
    - add $(${PKG_CONFIG} --cflags SDL2_mixer) to all C/C++ compiler
      command-lines
    - add $(${PKG_CONFIG} --libs SDL2_mixer) to linker command-line
    - include SDL.h (where required) with #include <SDL.h>
    - include SDL_mixer.h (where required) with #include <SDL_mixer.h>
    - if SDL2_image is required, do the same as for SDL2_mixer
    - if SDL2_image is not required, use #include <SDL.h> instead

- Change SDL2 so the assumptions are true again
  (for example <https://salsa.debian.org/sdl-team/libsdl2/merge_requests/3>
  which also resolves <https://bugs.debian.org/951087>)

I've verified that libsdl2 merge request 3 is sufficient to fix the
FTBFS (compiled successfully but not otherwise tested). However, for
best robustness, I think we would ideally do both.

    smcv



More information about the Pkg-sdl-maintainers mailing list