I made a C program and wrote the following two function in that
1. int c_add(lua_State* L)
{...some code here...
}
2. int main(int argc, char* argv)
{...some code here...
lua_register(L, "c_add", c_add);
}
And compiled it by following command successfully.
gcc -o test.exe test.c -I /home/ec2-user/install/lua-5.1.5/src -llua-5.1
But the following error showed after using a lua program to call it.
lua: func2.lua:2: attempt to call global 'c_add' (a nil value)
How to solve this problem?`
func2.luaand how are you running it?-- func2.luaprint(c_add(3,4))lua func2.lua.lua.exeis not thetest.exe. You havec_addfunction defined by the code intest.exe, so you must runfunc2.luafrom within thetest.exe