Lua - "multiple vms detected" when trying to add an extension for statically linked Lua

I have an application that contains a statically linked lua 5.2 inteperpreter (and does not have code access). When I try to write an extension using the following code:

#define LUA_LIB
#define LUA_BUILD_AS_DLL 
#include "lua.hpp"

extern "C" 
{
    static int test(lua_State* state)
    {
        return 1;
    }

    static const struct luaL_Reg functions[] = {
        {"test", test},
        {NULL, NULL},
    };

    int __declspec(dllexport) luaopen_test(lua_State* state)
    {
        luaL_newlibtable(state, functions);
        luaL_setfuncs(state, functions, 0);
        return 0;
    }
}

And compile it with statically linked lua52.lib. I get a "multiple vms detected" error when trying to require lua code from it. What can I do in this situation?

+4
source share
1 answer

lua52.lib, lua52.lib, "", , " ", .

( Windows): (1) (2) Lua52.dll, DLL "" DLL, API Lua ( API ).

, LuaProxyDllFour - DLL.

Linux -, Lua- , -Wl,-E linker; . htf.

+6

Source: https://habr.com/ru/post/1599748/


All Articles