且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Lua 脚本调用 C 共享库的***方式?

更新时间:2023-12-05 07:59:04

Lua 不能立即调用 C 库.它不附带 libffi,因此不像 ctypes 那样工作.

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

从历史上看,lua 被嵌入到一个应用程序中,该应用程序反过来会将所需的函数添加到 lua 表中,并提供 lua 堆栈操作来传递和返回参数.

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 是一个 libffi 改编版,可以正常工作.

Alien is a libffi adaptation and will work.