Create new C library in lua

不想你离开。 提交于 2019-12-20 03:56:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!