Hi, all.
I use wine gideros, and compile the dll lib,when use it in lua code, it dosen't work. The code is below:
#include
#include
#include
#include
#include "gideros.h"
static int test(lua_State *ls)
{
const char*str = lua_tostring(ls, -1);
printf("print from c lib: %s\n", str);
return 0;
}
static const luaL_Reg testlib[] ={
{"test", test},
{NULL, NULL}
};
LUALIB_API int luaopen_test(lua_State*ls)
{
luaL_register(ls, "test", testlib);
return 1;
}
static void g_initializePlugin(lua_State* L)
{
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");
lua_pushcfunction(L, luaopen_test);
lua_setfield(L, -2, "test");
lua_pop(L, 2);
}
static void g_deinitializePlugin(lua_State *L)
{ }
REGISTER_PLUGIN("myFirstPlugin", "1.0")
Now i use "require(test)", it not work. when i use "package.loadlib("test.dll", "luaopen_test")", it also not work.
if anyone can tell me i miss something?
Comments
#include <stdio.h>
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps