[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Please suggest me where am I wrong - require function of lua is failing.
- From: Muqtheear S <muqtheear.s@...>
- Date: Wed, 6 Mar 2013 16:50:04 +0530
Thanks in advance. Please let me know if I am not clear.
I have simple win32 application(see Lua_Test.cpp) that run the script (sample.lua).
In sample.lua, I am loading the dll(test.dll)
Problem: luaopen_test dll function is not called. Please see the below code and suggest me.
If you have any working solution, please share with me...
#define LUA_PATH_DEFAULT \
".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
#define LUA_CPATH_DEFAULT \
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
Lua_Test.cpp:
int _tmain ( int argc, char *argv[] )
{
int status;
/* initialize Lua */
L = lua_open();
/* load Lua base libraries */
luaL_openlibs(L);
/* load the script */
luaL_dofile(L, "sample.lua");
/* cleanup Lua */
lua_close(L);
/* pause */
printf( "Press enter to exit..." );
getchar();
return 0;
}
sample.lua:
f = require 'test'
test.dll:
#define LUA_API __declspec(dllexport)
LUALIB_API int luaopen_test (lua_State *L)
{
printf("Luaopen state\n");
luaL_openlib(L, "test", testlib, 0);
return 1;
}
Thanks & Regards,
Muqtheear.S