keharriso / love-nuklear

Lightweight immediate mode GUI for LÖVE games
MIT License
350 stars 32 forks source link

MSVC Support #52

Closed MikuAuahDark closed 4 years ago

MikuAuahDark commented 4 years ago

Since I have to ensure every external libraries I use is compiled with MSVC because LOVE is compiled with MSVC and I have to ensure (ABI) stability, I can't use the prebuilt binaries which is compiled with MinGW.

There are some modifications that needed to successfully compile it under MSVC

  1. Add LUA_BUILD_AS_DLL compile definitions to the CMake if the toolchain is MSVC.
  2. Add #define LUA_LIB in nuklear_love before #include <lua.h>.

Both steps is required to ensure luaopen_nuklear exported to the DLL. The build instruction, is easy.

rem Say, %LUA_DIR% is the LuaJIT dir, excluding the "src" dir
rem and you've invoked "msvcbuild.bat" under LuaJIT src directory
rem using VS command prompt, then build love-nuklear like this
cmake -Bbuild -H. -DLUA_INCLUDE_DIR=%LUA_DIR%\src -DLUA_LIBRARY=%LUA_DIR%\src\lua51.lib -DCMAKE_INSTALL_PREFIX=%CD%\install
cmake --build build --config Release --target install

Then you can found nuklear.dll in install folder ready to be used, compiled with MSVC.

keharriso commented 4 years ago

I followed your instructions and ended up with a .dll that crashes on start. Maybe you could make a quick pull request so I can test things the way you have them set up?

keharriso commented 4 years ago

Merged. Thanks a bunch!