windows module lua5.1 Compilation fails
MSVC with LUA_INC / LUA_LIB / LUA_LIB_NAME environment variables. Windows 10 ,mlua 5.0.1 I set up,but faild. Can you give a more detailed example or configuration
A first example is from github actions where I test Lua modules on Windows: https://github.com/khvzak/mlua/blob/master/.github/workflows/main.yml#L186
A second example is using Windows + MSVC
- Download binary Lua dll & lib (I used the luabinaries project, this file)
- Unzip to
lua51folder - Go to
mlua/examples/module - From git shell
$ LUA_INC=$HOME/Downloads/lua51/include LUA_LIB=$HOME/Downloads/lua51 LUA_LIB_NAME=lua5.1 cargo build --features lua51
Build ok, we got mlua/target/debug/rust_module.dll
For testing:
- Go to
mlua/target/debug - Run
$ lua5.1 -e 'print(require("rust_module").sum(2,3))'
5
$ lua5.1 -e 'print(require("rust_module").used_memory())'
35441
Windows 10, Latest MSVC Community, Git, Rust 1.49.0
Thank you very much for your reply. I succeeded !!! The reason for the failure is that Lua's lib was downloaded incorrectly. I succeeded in both Lua5.1 and Lua5.4
Now I have a new problem. The compiled DLL is required and executed correctly by Lua54.exe, but not by LuaQuire in Rust. Any solution, like this `use mlua::prelude::*;
fn main() -> LuaResult<()> { let lua = unsafe {Lua::new()}; lua.load(r#"print(require("my_module").sum(2,3))"#).exec()?;
Ok(())
}`
The line
let lua = unsafe {Lua::new()};
should be replaced with
let lua = unsafe { Lua::unsafe_new() };
to allow loading C modules
DLL is compiled in features=['lua54','module'] mode The rust project is compliated with eatures=['lua54','vendored'] mode
Lua library does not load properly without lua54. DLL, but I cannot find a way to link lua54. DLL to the library