问题
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 ?
回答1:
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.
This assumes your app calls luaL_openlibs
.
回答2:
Lua 5.2 has some API changes over 5.1/5.0 -- so use the reference for 5.2.3 instead. You can also buy Programming in Lua 3rd edition for 5.2, which has updated examples.
来源:https://stackoverflow.com/questions/25311192/create-new-c-library-in-lua