|
Am 01.04.2014 11:42 schrieb Richard Hundt:
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 asecond argument to `ffi.load`. I'm not sure if this solves anything foryou. My Windows fu is basically non-existent.
That would be an interesting approach. However, I have two issues with it. a) It would still load the lib at least twice as it is the lib itself, that executes the script, and therefore is already present at the time. b) It feels somehow 'hacky', 'non-canonical'. I was hoping that use case is so common, there must be a 'way to do' that is more like 'This is what everybody does'.
Thanks, Moose