Re: ffi.loaders? (RE: How to properly ffi.load a .dll file)

  • From: Cosmin Apreutesei <cosmin.apreutesei@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 16 Mar 2015 22:31:27 +0200

> In the case of ffi.load() I would have either to modify each external
> library code to use my custom loader instead of ffi.load(), which is
> impractical, or to to monkey patch ffi.load() itself, which is not ideal.

So you would like a built-in ffi.path/LUAJIT_FFIPATH feature similar
to package.path/LUA_PATH that would work for ffi.load, is that right?

So if package.path would contain "./?.lua" and ffi.path would contain
"./x86/?.dll", then that would allow `luajit -l foo` to find both
`foo.lua` and `x86/foo.dll` relative to the current directory. That
would be nice I guess. The problem is when foo.dll depends on bar.dll
and you want bar.dll to be searched for in ffi.path too. Since you
don't load bar.dll yourself, you need to tell the OS how to do that,
and I'm not sure there's a portable enough solution to that (eg. for
Windows that is XP SP3+ AFAIR).

Other related posts: