https://github.com/jprjr/lua-demo-module
A dummy C module that works with FFI and the traditional C api
https://github.com/jprjr/lua-demo-module
lua lua-module luajit luajit-ffi
Last synced: 10 months ago
JSON representation
A dummy C module that works with FFI and the traditional C api
- Host: GitHub
- URL: https://github.com/jprjr/lua-demo-module
- Owner: jprjr
- Created: 2017-02-02T20:32:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-02T21:18:45.000Z (almost 9 years ago)
- Last Synced: 2025-01-24T21:13:46.685Z (about 1 year ago)
- Topics: lua, lua-module, luajit, luajit-ffi
- Language: Lua
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lua-demo-module
This is just a silly example lua module written in C, I used this to
figure out how to create a C module that works in Lua and LuaJIT,
as well as with Lua/LuaJIT embedded into a C program.
You'll get slightly different output when using LuaJIT vs Lua, to show
whether you're using the traditional C API or the FFI API.
Files:
* demo.c - the module, compiles to 'demo/core.so' and 'demo/core.a'
* demo.lua - the loader, it will load 'demo/core.so'
* main.lua - a silly app that just uses the module
Some examples to try out:
```bash
make # builds demo/core.so and demo/core.a
lua main.lua
luajit main.lua
luastatic main.lua demo.lua /path/to/liblua.a demo/core.a -I/path/to/lua/include ; ./main
luastatic main.lua demo.lua /path/to/libluajit.a demo/core.a -I/path/to/luajit/include ; ./main
```
## LICENSE
This is in the public domain.