在 lua 中创建新的 C 库 [英] Create new C library in lua
问题描述
我想知道如何在 lua 5.2.3 中创建和使用新的 C 库.由于我在嵌入式系统上,我无法使用动态库(需要,共享库,...).我找到了一个答案,但它是针对 lua 5.0 (http://www.lua.org/pil/26.2.html),所以不兼容.如果有人有想法?
I want to know how i can create and use a new C library in lua 5.2.3. I can't use dynamic library (require, shared library, ...) due to I am on an embedded system. I found an answer but it is for lua 5.0 (http://www.lua.org/pil/26.2.html) and so it is not compatible. If someone have a idea ?
推荐答案
Edit linit.c
并将您的库入口点添加到其中.然后将修改后的 linit.c
添加到您的项目中.链接器将使用您的副本而不是 Lua 库中的副本.
Edit linit.c
and add your library entry point to it. Then add the modified linit.c
to your project. The linker will use your copy instead of the one in the Lua library.
这假设您的应用调用 luaL_openlibs
.
This assumes your app calls luaL_openlibs
.
这篇关于在 lua 中创建新的 C 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!