GitHunt
JP

jprjr/lua-demo-module

A dummy C module that works with FFI and the traditional C api

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:

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.

Languages

Lua69.3%Makefile19.8%C11.0%

Contributors

Created February 2, 2017
Updated August 21, 2018
jprjr/lua-demo-module | GitHunt