Hello,
I hit a problem to create a working DLL with OCaml for Windows 4.07.1+mingw32c, while it worked fine with 4.06.1+mingw32c.
I’m not sure if I missed some modification that occurred between those two versions?
I’d appreciate any help to understand the origin of this problem.
I wrote a trivial project to demonstrate the problem (it’s there, as a git repository). Interestingly, there is no line of OCaml in this demo project. Only dune
and C
files.
Below is a session that demonstrate the problem: it’s a C test file calling the generated DLL. I detected the problem while trying to load it from LabVIEW or Python.
- I’d like to have the confirmation that my problem can be reproduced
- And of course any hint toward a solution to it
Working switch
$ uname -a
CYGWIN_NT-10.0 DESKTOP-9DIKPMF 3.0.5(0.338/5/3) 2019-03-31 11:17 x86_64 Cygwin
$ opam switch
# switch compiler description
-> 4.06.1+mingw32c ocaml-variants.4.06.1+mingw32c 4.06.1+mingw32c
4.07.1+mingw32c ocaml-variants.4.07.1+mingw32c 4.07.1+mingw32c
$ git clone https://dubuget.fr/gitea/matthieu/test.git
Clonage dans 'test'...
remote: Décompte des objets: 12, fait.
remote: Compression des objets: 100% (9/9), fait.
remote: Total 12 (delta 0), reused 0 (delta 0)
Dépaquetage des objets: 100% (12/12), fait.
$ cd test
$ make test
dune build
cp tst_stub/mytst.h test
cp _build/default/dll/tst.dll test
cd test && i686-w64-mingw32-gcc -o test.exe tst.dll test.c
cd test && ./test.exe
Avant: 0
Après: 1
$ make clean
That is the expected result.
My test program just do:
#include <stdio.h>
#include <stdlib.h>
#include "mytst.h"
int main(){
int before, after;
before = tst_init_ok();
printf("Avant: %d\n", before);
fflush(stdout);
tst_init();
after = tst_init_ok();
printf("Après: %d\n", after);
fflush(stdout);
return EXIT_SUCCESS;
}
Failing switch
$ opam switch 4.07.1+mingw32c
# Run eval $(opam env) to update the current shell environment
$ eval $(opam env)
$ make test
dune build
cp tst_stub/mytst.h test
cp _build/default/dll/tst.dll test
cd test && i686-w64-mingw32-gcc -o test.exe tst.dll test.c
cd test && ./test.exe
C:/OCaml64/home/MatthieuDubuget/test/test/test.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
make: *** [Makefile:16: test] Error 127
Best regards