Home > other >  Lua dynamic library how to call DLL?
Lua dynamic library how to call DLL?

Time:04-15

I use VS19 generates a dynamic library, the dynamic library source code is as follows:
 # include & lt; iostream> 
Extern "C"
{
# include & lt; Lua. H>
# include & lt; Lualib. H>
# include & lt; Lauxlib. H>
}

Static int retStr (lua_State * L)
{
Lua_pushstring (L, "is this DLL return a string");
return 1;
}

The static const luaL_Reg util []={
{" getStr ", retStr},
{NULL NULL}
};

Extern "C" __declspec (dllexport)
Int luaopen_luacalldll (lua_State * L) {
LuaL_newlib (L, util);
return 1;
}


After generating the dynamic library, I in the same directory as the it made a lua files:
The lua file code is as follows:
 local obj=the require (" luacalldll ") 
Print (obj. GetStr ())


But I can't run the lua files, an error figure below:

Where is my wrong, why my DLL are generated, or can not call it?

  • Related