fccm / OCamlSDL2

OCaml interface to SDL 2.0 (for Linux, Windows, MacOS, and ChromeBook)
Other
51 stars 10 forks source link

error: use of undeclared identifier 'SDL_DISPLAYEVENT' #22

Closed cacilhas closed 3 years ago

cacilhas commented 3 years ago

Every time I try to install OCamlSDL2, the output is:

[ERROR] The compilation of ocamlsdl2 failed at "/home/cacilhas/.opam/opam-init/hooks/sandbox.sh build make -C src opt".

#=== ERROR while compiling ocamlsdl2.0.04 =====================================#
# context     2.0.8 | linux/x86_64 | ocaml-base-compiler.4.11.1 | https://opam.ocaml.org#d9cdb856
# path        ~/.opam/4.11.1/.opam-switch/build/ocamlsdl2.0.04
# command     ~/.opam/opam-init/hooks/sandbox.sh build make -C src opt
# exit-code   2
# env-file    ~/.opam/log/ocamlsdl2-15511-ad8886.env
# output-file ~/.opam/log/ocamlsdl2-15511-ad8886.out
### output ###
# sdlevent_stub.c:145:13: warning: enumeration values 'SDL_SCANCODE_AUDIOREWIND' and 'SDL_SCANCODE_AUDIOFASTFORWARD' not handled in switch [-Wswitch]
# [...]
#             ^
# sdlevent_stub.c:513:10: error: use of undeclared identifier 'SDL_DISPLAYEVENT'
#     case SDL_DISPLAYEVENT:               return Val_SDL_DISPLAYEVENT;
#          ^
# sdlevent_stub.c:520:10: error: use of undeclared identifier 'SDL_SENSORUPDATE'
#     case SDL_SENSORUPDATE:               return Val_SDL_SENSORUPDATE;
#          ^
# 1 warning and 2 errors generated.
# Makefile:193: recipe for target 'sdlevent_stub.o' failed
# make: *** [sdlevent_stub.o] Error 2
# make: Leaving directory '/home/cacilhas/.opam/4.11.1/.opam-switch/build/ocamlsdl2.0.04/src'

ocamlsdl2-15511-ad8886.out.gz

fccm commented 3 years ago

Hi, there is probably a mismatch between the version of SDL2 and the OCamlSDL2 bindings. There are 2 solutions in this case, either you install a more recent version of SDL2, or an older version of the ocaml bindings. A third solution is also to edit the source code file "sdlevent_stub.c" and remove the identifiers that don't exist in the headers of the SDL2 version that you're using.

If you like doing some packaging you can also help embedding the matching versions of SDL2 in the Opam packages. In the past it was not allowed in Opam, but today the Raylib package does so. We could probably do the same now for this binding.

cacilhas commented 3 years ago

I updated the SDL2 to version 2.0.14. After that, I was able to install OCamlSDL2.

Thanks!!