Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Problem for writing plugins with c on linux - Gideros Forum

Problem for writing plugins with c on linux

whhbestwhhbest Member
edited November 2012 in Plugins
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

Sign In or Register to comment.