Runtime error on missing symbols on Windows

I keep getting runtime errors of my app(s) which are build on Windows 10 (cygwin shell, mingw32_64 toolchain). If libraries using “native” code are linked to the executable, I get the following runtime error:
Fatal error: exception Dl.DL_error("dlsym: no such symbol")

So far, I could observe this with the following libraries: freetds & bimage-unix.
The same app builds and runs without problems on Ubuntu 18.04 (running on WSL on the same Win10 machine). The search paths should be correct, although I cannot not really check them, as I don’t know which symbol is actually missing.

I am a bit lost, as I don’t know where to start “debugging”: Is this a problem during building the involved libs? Is it caused by dune not correctly linking my app on Win10? Or could it be an issue with flexlink (the linking tool on Win)?

If someone observed the same problem, any help would be appreciated.

Best regards,
Kay-Uwe

This is caused by ctypes.foreign (freetds however doesn’t depend on ctypes…):

Does it work inside the toplevel or when you compile you program to byte code (whithout the -custom option)?

Thanks for the hint!
I get the same error, when building a byte code app (using (modes (byte exe))
in dune or loading the bimage-unix package in utop or ocaml (require "bimage-unix";;):

#require “bimage-unix”;;
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\ocaml: added to search path
C:/Opt/OCaml64/home/kayuwekirstein/.opam/4.10.0+mingw64c/lib/ocaml\unix.cma: loaded
C:/Opt/OCaml64/home/kayuwekirstein/.opam/4.10.0+mingw64c/lib/ocaml\bigarray.cma: loaded
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\bimage: added to search path
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\bimage\bimage.cma: loaded
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\bytes: added to search path
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\integers: added to search path
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\integers\integers.cma: loaded
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\ctypes: added to search path
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\ctypes\ctypes.cma: loaded
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\ctypes\ctypes-top.cma: loaded
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\ctypes\ctypes-foreign-base.cma:
loaded
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\ctypes\ctypes-foreign-unthreaded
.cma: loaded
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\bimage-unix: added to search pat
h
C:\Opt\OCaml64\home\kayuwekirstein.opam\4.10.0+mingw64c\lib\bimage-unix\bimage_unix.cma: loa
ded
Exception: Dl.DL_error “dlsym: no such symbol”.

BTW, there is an interesting mix-up in the path separator, but it looks like cygwin is handling this correctly.

Do you think, this can be fixed on the package side?

Try:

opam pin add bimage-unix 'https://github.com/fdopen/ocaml-bimage.git#visibility'

Perhaps it’s just an issue with the compile options. At least I can load it in the toplevel now.

Yes, it also works for my “native” apps. Thank you!

Are you planing to submit a PR to zshipko/ocaml-bimage (otherwise, I will do)?