Search code examples
luaembeddedlua-5.2lua-api

Create new C library in lua


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 ?


Solution

  • 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.