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 ?
Asked
Active
Viewed 1,030 times
2 Answers
4
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
.

lhf
- 70,581
- 9
- 108
- 149
-
I have one more problem. I make a script lua in which I call one of the function from my new library. I think I need to add a link between the script and the lua source like a require. But I have no idea, require seems not the answer. – Subas Aug 18 '14 at 12:20
1
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.

Advert
- 645
- 5
- 7