lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>Is this what libffi is for, or am I missing
>something? http://sourceware.org/libffi/

Pretty much, yes!

Abstracts all the complex guts of calling DLLs/.so files, which gets weirdly complex when you want to pass pointers, allocate objects, use function callbacks and the like.

There’s a really neat Lua binding here:

https://github.com/q66/cffi-lua

I’ve been meaning to promote it here for a month or three but kept forgetting. (Thanks to q66 for this library if they read this list!) 

It gives LuaJIT-type ease of writing quick-and-dirty bindings to system libraries that you only want to use in passing, without having to use LuaJIT.. 

I have cffi-lua and libffi compiled into my personal Lua binary “just in case”.

Have used it usefully for one-off Lua utilities where I wanted to make use of libmagic, libusb and some other stuff I have forgotten now. Some compression library, I think.

(Have only ever tried it on Linux x64, where it has worked well for me.)