Create new C library in lua

1.1k Views Asked by At

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 ?

2

There are 2 best solutions below

1
On BEST ANSWER

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.

0
On

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.