lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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