[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-09-20 (20:37) |
From: | David Allsopp <dra-news@m...> |
Subject: | RE: [Caml-list] External DLL call with mingw OCaml |
Matthieu Dubuget wrote: > 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). It is indeed not easy - fortunately, it's a once-only thing (for each DLL) > I'd like to know if there is a more simple way? Not as far as I'm aware - no site I've ever seen gives a reasonable explanation for why the "@nn" decorations are necessary (gcc or any other compiler should be able to infer it from the header at link time, but neither gcc nor the MS compilers provide a way to do this) <snip> > 3/ Import lib generation > dlltool --input-def visa.def --dllname Visa32.dll --output-lib > libvisa.a -k The irony is that the -k (--kill-at) removes the @nn from the symbols :o) <snip> > The main problem is that it is a trial error process in order to find > the @nn to add into visa.def. This shouldn't be trial and error - you can work out the numbers from the C definitions (which presumably you know as you're writing stubs). For the most part for 32-bit code, it'll be 4 x the number of parameters to the function but in more exact terms it's the number of bytes occupied by the parameters (so sizeof the *type* of each arg) which you can deduce from the .h file. Alternatively, you can just put them all as @0 initially and use the error messages - it'll always give you the correct one (provided that your headers are correct) Hope this reassures, even if it doesn't offer an easier way! David PS This is the site I used originally - http://www.emmestech.com/moron_guides/moron1.html though I'm not sure you'd ever find a moron who wanted/needed to do this kind of thing!!