Closed toots closed 2 years ago
thanks for the fix. In fact, since the ~from
workaround is needed only for Toplevel (afaik), we could also add something like this
let from = if !Sys.interactive
then Some (Dl.(dlopen ~filename:"libSDL2_image-2.0.so.0" ~flags:[RTLD_NOW]))
else None
let foreign name typ = foreign name typ ?from
Then for any system that has yet another different filename, it should still work at least for compiled programs. (of course we can combine this with your fix)
Btw since you have a mac, could you have a look at this other config: https://github.com/sanette/tsdl-ttf/pull/1 ?
thanks for the fix. In fact, since the
~from
workaround is needed only for Toplevel (afaik), we could also add something like thislet from = if !Sys.interactive then Some (Dl.(dlopen ~filename:"libSDL2_image-2.0.so.0" ~flags:[RTLD_NOW])) else None let foreign name typ = foreign name typ ?from
Then for any system that has yet another different filename, it should still work at least for compiled programs. (of course we can combine this with your fix)
As far as I can tell, the filename is also required for regular compilation, this issue is coming from a production build of https://github.com/savonet/liquidsoap/
on my system, if I ignore the ~from
argument of foreign
, it compiles fine, and I can link the library to other programs.
I only get an error when doing #require "tsdl-image";
from the toplevel.
What you are saying is that you get an error without the ~from
, outside of toplevel; is this correct?
put in another way, did you have the same issue with version 0.2?
on my system, if I ignore the
~from
argument offoreign
, it compiles fine, and I can link the library to other programs. I only get an error when doing#require "tsdl-image";
from the toplevel. What you are saying is that you get an error without the~from
, outside of toplevel; is this correct?
Confirmed. I have updated the PR to override foreign
only when running as top-level!
sounds good. Thanks!
let from = if !Sys.interactive
in fact this was a bad idea of mine... If you have a "toplevel file" like this one
#use "topfind";;
#thread;;
Printf.printf "Sys.interactive = %b\n" !Sys.interactive;;
#require "tsdl-image";;
Tsdl_image.Image.(init Init.empty) |> ignore
and execute this with ocaml
, the bug reappears because it is not considered interactive...
$ ocaml bug.ml
Sys.interactive = false
Exception:
Dl.DL_error
"/home/san/.opam/4.08.1/lib/stublibs/dllctypes-foreign_stubs.so: undefined symbol: IMG_Init".
File "./bug.ml", line 1:
Error: Reference to undefined global `Tsdl_image'
The shared library name is different on
macox
. This PR adds a build config which allows to pick the right name.