q66 / cffi-lua

A portable C FFI for Lua 5.1+
MIT License
176 stars 24 forks source link

Instructions to build with MSVC #45

Open roman-orekhov opened 4 months ago

roman-orekhov commented 4 months ago

Maybe this will save someone some headache

  1. Get python version 3 in PATH. I just happened to have 3.11, no issues
  2. Get meson. Docs don't specify the version but the project won't build with version <0.64. For this I used vcpkg from Git Bash:
    cd /c/vcpkg
    git pull
    ./bootstrap-vcpkg.sh
    # if you have one installed but it is old
    ./vcpkg remove vcpkg-tool-meson --recurse
    ./vcpkg install vcpkg-tool-meson
  3. Do not use libffi from vcpkg since it is a DLL not a static lib
  4. Make cffi/deps folder and put whatever the docs say you need to put there. I've put this tree there lua53.dll lua53.lib lua53.exe include\lauxlib.h include\lua.h include\luaconf.h include\lualib.h include\lua.hpp
  5. mkdir cffi/build
  6. Now open a developer command prompt from Visual Studio in this folder and do this for default buildtype (debugoptimized). Use your paths. Git is needed to grab libffi. --skip-subprojects is needed to not install it since it is a static lib.
    set PATH=C:\Work\Tools\Git\bin;%PATH%
    python c:\vcpkg\downloads\tools\meson-1.3.2-d646d3\meson.py setup .. -Dlua_version=vendor -Dlua_install_path=c:\Work\Tools\qlua\lib\lua\@0@\debug
    ninja all
    ninja test
    python c:\vcpkg\downloads\tools\meson-1.3.2-d646d3\meson.py install --skip-subprojects
  7. This got installed
    Installing cffi.dll to c:\Work\Tools\qlua\lib\lua\5.3\debug
    Installing cffi.lib to c:\Work\Tools\qlua\lib\lua\5.3\debug
    Installing cffi.pdb to c:\Work\Tools\qlua\lib\lua\5.3\debug
  8. For a release build do this instead:
    set PATH=C:\Work\Tools\Git\bin;%PATH%
    python c:\vcpkg\downloads\tools\meson-1.3.2-d646d3\meson.py setup .. -Dlua_version=vendor -Dlua_install_path=c:\Work\Tools\qlua\lib\lua\@0@ -Dbuildtype=release
    ninja all
    ninja test
    python c:\vcpkg\downloads\tools\meson-1.3.2-d646d3\meson.py install --tags runtime
  9. This will get installed Installing cffi.dll to c:\Work\Tools\qlua\lib\lua\5.3