Compile bindings "ocaml-irrlicht"

Hi, I would like to compile ocaml-irrlicht, an old binding to the Irrlicht 3D engine (last commit from 2012).

The bindings are written for Irrlicht 1.7.X and I installed last stable 1.8.4.
I don’t know yet if there are a lot of API changes, for now I’m having difficulty to find how to generate the file "irr_enums_wrap_poly_values.h"

Here is my temporary build script:

make -C enums/
# reads: irr_enums.txt
# writes:
#  irr_enums.mli
#  irr_enums_wrap_values.h
#  irr_enums_poly_values.txt
#  irr_enums_wrap_conv.cpp
#  irr_enums_wrap_conv.h
./enums/main.byte

ocamlc -c irr_enums.mli
ocamlc -c irr_core.mli
ocamlc -c irr_base.mli
ocamlc -c irr_video.mli
ocamlc -c irr_gui.mli
ocamlc -c irr_io.mli
ocamlc -c irr_scene.mli
ocamlc -c irr.mli

ocamlc -c irr_core.ml
ocamlc -c irr_base.ml
ocamlc -c irr_video.ml
ocamlc -c irr_gui.ml
ocamlc -c irr_io.ml
ocamlc -c irr_scene.ml
ocamlc -c irr.ml

make -C hash_values/
./hash_values/main.byte methods_hash_values.txt > methods_hash_values.h

g++ -o irr_base_wrap.o -I`ocamlc -where` -c -I/usr/include/irrlicht  irr_base_wrap.cpp
g++ -o irr_scene_wrap.o -I`ocamlc -where` -c -I/usr/include/irrlicht  irr_scene_wrap.cpp
g++ -o irr_core_wrap.o -I`ocamlc -where` -c -I/usr/include/irrlicht  irr_core_wrap.cpp

g++ -o irr_gui_wrap.o -I`ocamlc -where` -c -I/usr/include/irrlicht  irr_gui_wrap.cpp
g++ -o irr_io_wrap.o -I`ocamlc -where` -c -I/usr/include/irrlicht  irr_io_wrap.cpp

g++ -o irr_video_wrap.o -I`ocamlc -where` -c -I/usr/include/irrlicht  irr_video_wrap.cpp
g++ -o irr_wrap.o -I`ocamlc -where` -c -I/usr/include/irrlicht  irr_wrap.cpp

I just changed enums/main.ml like this:

diff --git a/enums/main.ml b/enums/main.ml
index e37b64d..1a0218a 100644
--- a/enums/main.ml
+++ b/enums/main.ml
@@ -8,8 +8,10 @@ let get_dec () =
 
 let ml_name e s =
   let s1 = String.sub s e.prefix (String.length s - e.prefix) in
-  let s2 = String.lowercase s1 in
-  if not e.poly then s2.[0] <- Char.uppercase s2.[0];
+  let s2 = String.lowercase_ascii s1 in
+  let s2 =
+    if e.poly then s2 else String.capitalize_ascii s2
+  in
   if s2 = "end" then "ends"
   else match s2.[0] with
   | '0'..'9' -> sprintf "_%s" s2

The error is raised with the first g++ command:
fatal error: irr_enums_wrap_poly_values.h: No such file

If someone is more clever than me to find how to generate this file, it would be nice.

You may get a hint from OPAM build longs : https://opam.ocaml.org/builds/9eba5cf215c0ced35633b47b9fe82130514541f5/logs/local-centos-7-ocaml-4.02.1/raw/irrlicht.html

For example, it looks like you are missing a build command

hash_values/main.byte irr_enums_poly_values.txt > irr_enums_wrap_poly_values.h

Cheers!
Nicolás

1 Like

Thanks!
I’m now able to compile the bindings. There was only one API change in the stubs files. I’ve written a new Makefile to replace the oasis build, this fork is there.