ARTICLE AD BOX
#pragma message("Lua include: " __FILE__)
#include "ScriptHandler.h"
#include <iostream>
#include "SDL3/SDL_log.h"
bool ScriptHandler::DeclareLuaState()
{
luaState = luaL_newstate();
if (luaState != nullptr)
{
luaL_openlibs(luaState);
return true;
}
return false;
}
bool ScriptHandler::Init()
{
if (this->DeclareLuaState())
{
if (luaL_dofile(luaState, "../Game/hoved.lua") == LUA_OK)
{
lua_getglobal(luaState, "Init");
lua_pcall(luaState, 0, 1, 0);
bool initResult = true;
if (lua_isboolean(luaState, -1))
initResult = lua_toboolean(luaState, -1);
return initResult;
}
std::cout << "ScriptHandler.Init() - Cannot load hoved.lua!\n";
return false;
}
std::cout << "ScriptHandler.Init() - Cannot initialise Lua!\n";
return false;
}
void ScriptHandler::Liquidate()
{
lua_close(luaState);
}
void ScriptHandler::Update(float deltaTime)
{
}
This is the actual code that tries to load a given lua file, and it seems to be talking about either the linking to Lua by what appears to be when I try running luaL_openlibs(luaState). I tried wrapping the include for <lua.h> with extern "C" {} and that reduced my errors from 8 to 3, but it seemed even more ambiguous.
Build with surface heuristics started at 18:25:09 Use build tool: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe CONSOLE: MSBuild version 17.12.12+1cce77968 for .NET Framework CONSOLE: Build started 28/02/2026 6:25:09 PM. CONSOLE: Project "C:\Users\jbart\AppData\Local\Temp\Gifipot.proj" on node 1 (default targets). CONSOLE: ControllerTarget: CONSOLE: Run controller from C:\Program Files\JetBrains\Rider\r2r\2024.2.7R\F4DEACA99BED530D67D4930D1596689\JetBrains.Platform.MsBuildTask.v17.dll 0>------- Started building project: Rose C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX64\x64\CL.exe /c /I"K:\github\vcpkg\installed\x64-windows\include" /I"K:\Graphics Libraries\SDL\SDL3\SDL-release-3.4.2\include" /IK:\Rider\Projects\Rose /I"K:\github\vcpkg\installed\x64-windows\include" /I"K:\github\vcpkg\installed\x64-windows\include" /ZI /JMC /nologo /W3 /WX- /diagnostics:column /sdl /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /permissive- /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"x64\Debug\\" /Fd"x64\Debug\vc142.pdb" /external:env:EXTERNAL_INCLUDE /external:W3 /Gd /TP /FC /errorReport:prompt Engine\Engine.cpp Engine\ScriptHandler.cpp Main.cpp Engine.cpp ScriptHandler.cpp Lua include: K:\Rider\Projects\Rose\Engine\ScriptHandler.cpp Main.cpp Generating Code... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX64\x64\link.exe /ERRORREPORT:PROMPT /OUT:"K:\Rider\Projects\Rose\x64\Debug\Rose.exe" /INCREMENTAL /ILK:"x64\Debug\Rose.ilk" /NOLOGO /LIBPATH:"K:\github\vcpkg\installed\x64-windows\debug\lib" /LIBPATH:"K:\github\vcpkg\installed\x64-windows\debug\lib\manual-link" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "K:\github\vcpkg\installed\x64-windows\debug\lib\lua.lib" "K:\github\vcpkg\installed\x64-windows\debug\lib\*.lib" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"K:\Rider\Projects\Rose\x64\Debug\Rose.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"K:\Rider\Projects\Rose\x64\Debug\Rose.lib" /MACHINE:X64 x64\Debug\Colour.obj x64\Debug\Engine.obj x64\Debug\ScriptHandler.obj x64\Debug\Screen.obj x64\Debug\Main.obj K:\Rider\Projects\Rose\x64\Debug\SDL3.lib 0>ScriptHandler.obj: Error LNK2019 : unresolved external symbol "__declspec(dllimport) void __cdecl lua_close(struct lua_State *)" (__imp_?lua_close@@YAXPEAUlua_State@@@Z) referenced in function "public: void __cdecl ScriptHandler::Liquidate(void)" (?Liquidate@ScriptHandler@@QEAAXXZ) 0>ScriptHandler.obj: Error LNK2019 : unresolved external symbol "__declspec(dllimport) int __cdecl lua_type(struct lua_State *,int)" (__imp_?lua_type@@YAHPEAUlua_State@@H@Z) referenced in function "public: bool __cdecl ScriptHandler::Init(void)" (?Init@ScriptHandler@@QEAA_NXZ) 0>ScriptHandler.obj: Error LNK2019 : unresolved external symbol "__declspec(dllimport) int __cdecl lua_toboolean(struct lua_State *,int)" (__imp_?lua_toboolean@@YAHPEAUlua_State@@H@Z) referenced in function "public: bool __cdecl ScriptHandler::Init(void)" (?Init@ScriptHandler@@QEAA_NXZ) 0>ScriptHandler.obj: Error LNK2019 : unresolved external symbol "__declspec(dllimport) int __cdecl lua_getglobal(struct lua_State *,char const *)" (__imp_?lua_getglobal@@YAHPEAUlua_State@@PEBD@Z) referenced in function "public: bool __cdecl ScriptHandler::Init(void)" (?Init@ScriptHandler@@QEAA_NXZ) 0>ScriptHandler.obj: Error LNK2019 : unresolved external symbol "__declspec(dllimport) int __cdecl lua_pcallk(struct lua_State *,int,int,int,__int64,int (__cdecl*)(struct lua_State *,int,__int64))" (__imp_?lua_pcallk@@YAHPEAUlua_State@@HHH_JP6AH0H1@Z@Z) referenced in function "public: bool __cdecl ScriptHandler::Init(void)" (?Init@ScriptHandler@@QEAA_NXZ) 0>ScriptHandler.obj: Error LNK2019 : unresolved external symbol "__declspec(dllimport) void __cdecl luaL_openselectedlibs(struct lua_State *,int,int)" (__imp_?luaL_openselectedlibs@@YAXPEAUlua_State@@HH@Z) referenced in function "public: bool __cdecl ScriptHandler::DeclareLuaState(void)" (?DeclareLuaState@ScriptHandler@@QEAA_NXZ) 0>ScriptHandler.obj: Error LNK2019 : unresolved external symbol "__declspec(dllimport) int __cdecl luaL_loadfilex(struct lua_State *,char const *,char const *)" (__imp_?luaL_loadfilex@@YAHPEAUlua_State@@PEBD1@Z) referenced in function "public: bool __cdecl ScriptHandler::Init(void)" (?Init@ScriptHandler@@QEAA_NXZ) 0>ScriptHandler.obj: Error LNK2019 : unresolved external symbol "__declspec(dllimport) struct lua_State * __cdecl luaL_newstate(void)" (__imp_?luaL_newstate@@YAPEAUlua_State@@XZ) referenced in function "public: bool __cdecl ScriptHandler::DeclareLuaState(void)" (?DeclareLuaState@ScriptHandler@@QEAA_NXZ) 0I don't really know where I went wrong - I added the lua files to my additional include directories, and I linked lua.lib through the Linker...
