C++:
int Add(int x, int y) { return x + y; }
Lua:
print(Add(3,12))
int Add(int x, int y) { return x + y; }
print(Add(3,12))
#define LUA_LIB #define LUA_BUILD_AS_DLL extern "C" { #include <lua.h> #include <lualib.h> #include <lauxlib.h> } int Add(lua_State *L) { 	double x=luaL_checknumber(L,1); 	double y=luaL_checknumber(L,2); 	lua_pushnumber(L,x+y); 	return 1; } luaL_reg function_list_that_want_to_exported_to_lua[]={ 	{"Add",Add}, }; extern "C" int __declspec(dllexport) luaopen_thelibraryname(lua_State *L) { 	luaL_register(L,"LibraryName",function_list_that_want_to_exported_to_lua); 	return 1; }