lua-users home
lua-l archive

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


On 4/1/14 11:20 AM, Moose wrote:
> Am 01.04.2014 10:49 schrieb steve donovan:
>> Sounds like the FFI isn't able to find the symbol within the
>> executable (embedded LuaJIT, I'm assuming).  Does the executable
>> export anything? (try dump the symbols).
>
> The executable itself is in my case a unit test that links against the
> dll that exposes the functions. The executable itself does not expose
> anything.
> Microsofts dependency walker shows that the DLL exposes the C
> functions all right. After all, it works when I explicitly load() the
> DLL.
>
If this works and you're concerned about loading the DLL more than once,
then you can wrap it in a module:

-- bar.lua
local ffi = require('ffi')
local lib = ffi.load('yourlib')
return lib

then later:
lib = require("bar")

The `require` function caches the module, so it only happens once. If
you want your symbols in the `ffi.C` namespace, then pass `true` as a
second argument to `ffi.load`. I'm not sure if this solves anything for
you. My Windows fu is basically non-existent.