I compiled and tested your bindings with ocaml 4.11.1
/ allegro 5.2.8
under debian 12.
Debian 12 provides:
liballegro-acodec5-dev
liballegro-acodec5.2
liballegro-audio5-dev
liballegro-audio5.2
liballegro-dialog5-dev
liballegro-dialog5.2
liballegro-image5-dev
liballegro-image5.2
liballegro-physfs5-dev
liballegro-physfs5.2
liballegro-ttf5-dev
liballegro-ttf5.2
liballegro-video5-dev
liballegro-video5.2
liballegro5-dev
liballegro5.2
but I only had to install liballegro5-dev
and liballegro5.2
Debian 12 also provides dune
but its version is not compatible with your bindings, so I had to write my own Makefile
in order to compile your project.
$ dune build
File "dune-project", line 1, characters 11-15:
1 | (lang dune 3.11)
^^^^
Error: Version 3.11 of the dune language is not supported.
Supported versions of this extension in version 3.11 of the dune language:
- 1.0 to 1.12
- 2.0 to 2.9
here is my patch for ocaml 4.11.1
:
diff --git a/lib/events.c b/lib/events.c
index 020525a..64b92f2 100644
--- a/lib/events.c
+++ b/lib/events.c
@@ -1,5 +1,17 @@
#include "keyboard.h"
+#if OCAML_VERSION < 41200
+#define Val_none Val_int(0)
+static value
+caml_alloc_some(value v)
+{
+ CAMLparam1(v);
+ CAMLlocal1(some);
+ some = caml_alloc(1, 0);
+ Store_field(some, 0, v);
+ CAMLreturn(some);
+}
+#endif
CAMLprim value ml_al_create_event_queue(value unit)
{
diff --git a/lib/font.c b/lib/font.c
index cd6cce9..cffd192 100644
--- a/lib/font.c
+++ b/lib/font.c
@@ -3,6 +3,11 @@
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
+#if OCAML_VERSION < 41200
+#define Some_val(v) Field(v,0)
+#define Val_none Val_int(0)
+#define Is_none(v) (v == Val_none)
+#endif
CAMLprim value ml_al_init_font_addon(value unit)
{
diff --git a/lib/graphics.c b/lib/graphics.c
index 12beffa..deb5a9f 100644
--- a/lib/graphics.c
+++ b/lib/graphics.c
@@ -1,5 +1,10 @@
#include "graphics.h"
+#if OCAML_VERSION < 41200
+#define Val_none Val_int(0)
+#define Is_none(v) (v == Val_none)
+#define Some_val(v) Field(v,0)
+#endif
static struct custom_operations allegro_color_ops = {
"org.allegro5.color",
diff --git a/test/test_ocaml_allegro.ml b/test/test_ocaml_allegro.ml
index 04ff709..c2421a3 100644
--- a/test/test_ocaml_allegro.ml
+++ b/test/test_ocaml_allegro.ml
@@ -205,8 +205,8 @@ let () =
| Failure _ -> ()
in
- let rsrc_folder = List.hd Sites.Sites.ocaml_allegro5 in
- let alleg_img = Al5.load_bitmap (Filename.concat rsrc_folder "allegator.png") in
+ let dirname = Filename.dirname Sys.argv.(0) in
+ let alleg_img = Al5.load_bitmap (Filename.concat dirname "allegator.png") in
MouseLine.alleg_img := Some alleg_img;
let font = Al5.create_builtin_font () in
here is my Makefile
:
LINK = -lallegro -lallegro_primitives -lallegro_font -lallegro_ttf -lallegro_image
al5.cma: al5.cmo dllalleg_stubs.so
ocamlc -a -o $@ $< -dllib -lalleg_stubs -cclib '$(LINK)'
dllalleg_stubs.so: al5.o display.o events.o font.o graphics.o image.o keyboard.o mouse.o primitives.o system.o time.o timer.o
ocamlmklib -o alleg_stubs $^ $(LINK)
al5.cmo: al5.ml al5.cmi
ocamlc -c $<
al5.cmi: al5.mli
ocamlc -c $<
%.o: %.c
ocamlopt -c $<
clean:
$(RM) *.so *.cmxa *.cm[ioxa] *.o *.a
Then the test file works fine, but I suspect that the joystick problem that I have with SDL2 in crostini is also there with alleg5.