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

Norbert Preining norbert at preining.info
Fri Apr 14 17:37:09 CEST 2023


Hi Christophe,

> I hope this is the right place to post.

I guess the luatex-dev mailing list is better for that, but I try to
answer what I can.

> I'm currently writing a generic luatex package that relies on an
> external library (https://github.com/CoolProp/CoolProp) called via the
> FFI library in luatex (WIP:

Good luck.

> https://github.com/cjorssen/luatex-coolprop). 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

Then maybe doing a ffi based library development might be rather on the
challenging side...

> 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?

No idea. I don't think kpsewhich is used, but the normal ldconfig /
ld.so library path. But I might be wrong.

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

Compilation on user computer is out of discussion, since you cannot know
whether a compiler is installed.

> 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?

Please ask on the luatex-dev or luatex user lists.

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

I guess there are some ways to cross compile, but that is rather tricky.

> 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?

Good point, I guess it is ok.

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

Yes.

Best

Norbert

--
PREINING Norbert                              https://www.preining.info
Mercari Inc.     +     IFMGA Guide     +     TU Wien     +     TeX Live
GPG: 0x860CDC13   fp: F7D8 A928 26E3 16A1 9FA0 ACF0 6CAC A448 860C DC13


More information about the tex-live mailing list.