Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error LNK2019: unresolved external symbol _luaJIT_setmode

I have this piece of code (file luascript.cpp):

bool LuaInterface::initState()
{
    m_luaState = luaL_newstate();
    if(!m_luaState)
        return false;

    luaL_openlibs(m_luaState);
#ifdef __LUAJIT__
    luaJIT_setmode(m_luaState, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_ON);
#endif

    registerFunctions();
    if(!loadDirectory(getFilePath(FILE_TYPE_OTHER, "lib/"), false, true))
        std::clog << "[Warning - LuaInterface::initState] Cannot load " << getFilePath(FILE_TYPE_OTHER, "lib/") << std::endl;

    lua_newtable(m_luaState);
    lua_setfield(m_luaState, LUA_REGISTRYINDEX, "EVENTS");
    m_runningEvent = EVENT_ID_USER;
    return true;
}

the declaration (file luajit.h):

LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode);

and the error is:

1>luascript.obj : error LNK2019: unresolved external symbol _luaJIT_setmode referenced in function "public: virtual bool __thiscall LuaInterface::initState(void)" (?initState@LuaInterface@@UAE_NXZ)
1>C:\Users\GUIAKI\Documents\trunk.r5918\vc10\Debug\tfs.exe : fatal error LNK1120: 1 unresolved externals

How can I solve it?

like image 428
Guilherme Garcia Avatar asked Mar 17 '26 18:03

Guilherme Garcia


1 Answers

Simply remove that line.

You can't link against plain Lua, if you keep it. And if you link against LuaJIT, the JIT compiler is enabled by default, anyway. That line of code is utterly pointless.

like image 62
Mike Pall Avatar answered Mar 20 '26 08:03

Mike Pall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!