Luabridge 无法工作,没有"luaL_openlibs(L)"

我无法在没有以下几行代码的情况下使用lubridge:

luaL_openlibs(lState);

而且我甚至不使用库函数。

我遇到了以下错误:

Assertion failed: lua_istable (L, -1)

只要添加"luaL_openlibs(lState)", 就不会出现问题,但我不想使用lua的库,并确保它们没有被包含。

我的主函数如下:

lua_State* lState = luaL_newstate();
    //luaL_openlibs(lState);
    getGlobalNamespace(lState).addFunction("log", print).beginNamespace("math").addFunction("sin", &std::sinf);

    luaL_dofile(lState, "res/script.lua");

    LuaRef start = getGlobal(lState, "start");

    try {
        start();
    } catch (const LuaException& e) {
        std::cout << e.what();
    }

    lua_close(lState);
    std::cin.get();
点赞