libffi-d: D binding to libffi

Alex Rønne Petersen xtzgzorex at gmail.com
Thu Dec 15 00:14:59 PST 2011


Hi Andrej,

Sorry for the late response (for some reason, my news reader had marked 
this thread as read).

 > There's a few DLL's floating around for libffi, however none of them
 > seem to have the symbol "ffi_prep_cif_var" which seems to be needed
 > for variadic functions.
 >
 > I can version variadic support out and compile your bindings, the
 > tests will work fine on win32.
 > I've also tried compiling libffi on my own but had no success.

ffi_prep_cif_var doesn't seem to be available in any Windows builds 
(Cygwin, MinGW, or otherwise) of libffi for whatever reason. I'll 
version it out on Windows for now, as you suggested.

I haven't managed to get a MinGW build of libffi working so far, but I 
did manage to get one working under Cygwin. Build libffi like this:

$ ./configure --enable-static=yes --enable-shared=no
$ make

Now you should have i686-pc-cygwin/.libs/libffi.a.

You'll also need your Cygwin installation's libgcc.a:

$ cd i686-pc-cygwin/.libs
$ ar -r libffi.a /lib/gcc/i686-pc-cygwin/4.5.3/libgcc.a

Now you need to convert the .a to an OMF .lib. You'll need objconv.zip 
from this page: http://www.agner.org/optimize/

$ objconv -fomf -nu libffi.a libffi.lib

libffi.lib should now be linkable with DMD.

(I long for the day DMD doesn't use OMF.)

 > I can make a pull with the import lib, the DLL (it's only 99KB), and
 > the versioned out sections, if you'd like that.

I prefer keeping the binaries out of Git for various portability, 
licensing, etc issues. That being said, I think we could upload 
.libs/.dlls as downloads on the GitHub page. The question is whether we 
should put .libs or .dlls there? Personally, I think .libs are easier to 
work with when using DMD.

Thanks for the input!

- Alex


More information about the Digitalmars-d-announce mailing list