caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* External DLL call with mingw OCaml
@ 2009-09-20 19:34 Matthieu Dubuget
  2009-09-20 20:37 ` [Caml-list] " David Allsopp
  0 siblings, 1 reply; 2+ messages in thread
From: Matthieu Dubuget @ 2009-09-20 19:34 UTC (permalink / raw)
  To: caml-list

Hello,

recently, I had to call a third-party DLL (Windows, mingw flavour of OCaml).
It was not easy, because of symbol names decorations (I think).
I'd like to know if there is a more simple way?

Here is the way I found, after asking some questions to internet:

1/ First I had to create a .def file for the third party DLL:
pexports.exe Visa32.dll > visa.def

2/ Then I had to edit the visa.def file, in order to add @nn to symbol 
names.

3/ Import lib generation
dlltool --input-def visa.def --dllname Visa32.dll --output-lib libvisa.a -k

4/ My C-stub, that give access to the functions of Visa32.dll to OCaml
ocamlc -c test_stub.c

Is then turned into a library that depends on Visa32.dll
ocamlmklib -o test_dll -lvisa test_stub.o

5/ Test module compilation
ocamlc -c test.ml
ocamlc -a -o test.cma -dllib dlltest_dll test.cmo

6/ Load test.cma into toplevel


The main problem is that it is a trial error process in order to find 
the @nn to add into visa.def.
I deduce them from the error message I receive (I don't remember if this 
is at step 5/ or 6/) about
visa_function@nn that can't be found.

Salutations

Matthieu Dubuget


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-09-20 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-20 19:34 External DLL call with mingw OCaml Matthieu Dubuget
2009-09-20 20:37 ` [Caml-list] " David Allsopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).