Best way for Lua script to call a C shared lib?

前端 未结 2 1792
礼貌的吻别
礼貌的吻别 2021-01-13 01:36

I come from more of a Python and CTYPES background...and am trying to work out the best way to call a standard C shared lib from Lua script.

I have heard of \"Alien\

2条回答
  •  温柔的废话
    2021-01-13 01:53

    Lua cannot call C libraries out of the box. It does not ship with libffi, and as such doesn't work like ctypes.

    Historically, lua is embedded into an application which in turn will add to the lua tables the needed functions and provide the lua stack manipulation to pass and return parameters.

    Alien is a libffi adaptation and will work.

提交回复
热议问题