How should I deal with packages that require FFI external libraries?

Christophe Jorssen christophe.jorssen at
Fri Apr 14 14:38:53 CEST 2023

Hello all,

I hope this is the right place to post.

I'm currently writing a generic luatex package that relies on an
external library ( called via the
FFI library in luatex (WIP: I'm not an expert at
compiling complex projects (I can read a `README` file and type
`make`), neither at binding C to lua, nor at the subtleties of OS and
architectures. So please forgive me if I don't use the correct
vocabulary and/or if I misunderstand something.

I work under linux but I'd like to make the package available for
windows and macos.

1) When the external library is loaded, I have something like:

lib = ffi.load('<path to the .so file>')

For now, the path is hardcoded. Where should I put the .so file so
that luatex finds it? What is good practice for CTAN/TeXLive? Does
luatex rely on kpsewhich for that kind of thing?

2) Can I distribute the .so file (or .dll) with the CTAN/TeXLive
package or should it be compiled on the user computer?

3) Does FFI work in luatex on all architectures supported by TeXlive?
By the way, I cannot find any reference to the ffi library in the
luatex manual: I missed something?

4) Can I compile the library for windows and macos on my linux
computer? (Sorry, I know it is out of scope.)

5) Regarding security, I don't think it is an issue since ffi est
shell-escape protected by default in TeXLive. But what do you think?

6) Regarding the licence: the library has an MIT licence. Is it ok for TeXLive?

Many thanks.

Best regards


More information about the tex-live mailing list.