fccm / OCamlSDL2

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

Fatal error: cannot load shared library dllsdl2_stubs #33

Open idimension18 opened 1 year ago

idimension18 commented 1 year ago

Hi, I am on manjaro (arch linux base distro) I tried to compile a game with ocamlc + ocamlfind and it works. But when I run the executable I get the error : Fatal error: cannot load shared library dllsdl2_stubs Reason: /home/idimension/.opam/default/lib/stublibs/dllsdl2_stubs.so: undefined symbol: SDL_WriteBE32

SDL2 version : 2.26.5 OCaml version : 4.14.0

fccm2 commented 1 month ago

If you don't need this function (this is probably the case), just remove it from the sources. Here is the patch:

diff --git a/src/sdlrwops.ml b/src/sdlrwops.ml
index 64fac6b..185e9f4 100644
--- a/src/sdlrwops.ml
+++ b/src/sdlrwops.ml
@@ -72,7 +72,6 @@ module BigEndian = struct
   external read64 : t -> uint64 = "caml_SDL_ReadBE64"

   external write16 : t -> uint16 -> unit = "caml_SDL_WriteBE16"
-  external write32 : t -> uint32 -> unit = "caml_SDL_WriteBE32"
   external write64 : t -> uint64 -> unit = "caml_SDL_WriteBE64"

 end
diff --git a/src/sdlrwops.mli b/src/sdlrwops.mli
index 3f6e106..23d0880 100644
--- a/src/sdlrwops.mli
+++ b/src/sdlrwops.mli
@@ -86,9 +86,6 @@ module BigEndian : sig
   external write16 : t -> uint16 -> unit = "caml_SDL_WriteBE16"
   (** {{:http://wiki.libsdl.org/SDL_WriteBE16}api doc} *)

-  external write32 : t -> uint32 -> unit = "caml_SDL_WriteBE32"
-  (** {{:http://wiki.libsdl.org/SDL_WriteBE32}api doc} *)
-
   external write64 : t -> uint64 -> unit = "caml_SDL_WriteBE64"
   (** {{:http://wiki.libsdl.org/SDL_WriteBE64}api doc} *)
 end
diff --git a/src/sdlrwops_stub.c b/src/sdlrwops_stub.c
index 0649505..f940c52 100644
--- a/src/sdlrwops_stub.c
+++ b/src/sdlrwops_stub.c
@@ -165,7 +165,6 @@ write_int_stub(Uint8, SDL_WriteU8, "writeU8")
 write_int_stub(Uint16, SDL_WriteLE16, "LittleEndian.write16")
 write_int_stub(Uint16, SDL_WriteBE16, "BigEndian.write16")
 write_int_stub(Uint32, SDL_WriteLE32, "LittleEndian.write32")
-write_int_stub(Uint32, SDL_WriteBE32, "BigEndian.write32")
 write_int_stub(Uint64, SDL_WriteLE64, "LittleEndian.write64")
 write_int_stub(Uint64, SDL_WriteBE64, "BigEndian.write64")
fccm2 commented 1 month ago

Recent versions of ocaml provide an equivalent function:

String.get_int32_be : string -> int -> int32
36000000 commented 1 day ago

Please confirm:

git apply patch
cd src
cp Makefile.config.unix Makefile.config
make gen
make dep
make opt byte
cd ..
opam install .
utop
#use topfind;;
#require sdl2;;
Cannot load required shared library dllsdl2_stubs.
Reason: /home/user/.opam/default/lib/stublibs/dllsdl2_stubs.so: /home/user/.opam/default/lib/stublibs/dllsdl2_stubs.so: undefined symbol: SDL_WriteBE32.

The issue persists.