Search code examples
windowsvcpkgluajitsol3

What is the correct way to link LuaJIT with Sol2?


Using windows, visual studio 2022, vcpkg

Installing sol2 in vcpgk installs lua package aswell. By my understanding installing luajit and linking within a project like this wont work:

#include <sol/sol.hpp>
#include <luajit/lua.h>
#include <luajit/lualib.h>
#include <luajit/lauxlib.h>

Going into luajit/lauxlib.h in visual studio shows all the code grayed out, which im assuming means that the code within the define is not included because sol already links lua.h.

What is the correct way to link and use LuaJIT with SOL?


Solution

  • The problem was that if you included sol.hpp it would include lua.h from its own installed dependency, the way to fix this is not to use vcpgk installed sol library and just include the files yourself and add luajit folder in include directories in visual studio. That way it would include the lua files from luajit library and not normal lua.