Extract from lua.org
When we say that Lua can call C functions, this does not mean that Lua can call any C function.(There are packages that allow Lua to call any C function, but they are neither portable nor robust.) ... ... for a C function to be called from Lua, we must register it, that is, we must give its address to Lua in an appropriate way.
You should have a look here