-
Notifications
You must be signed in to change notification settings - Fork 117
Cannot load DLLs in v0.19 #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, In 0.19.x, by default, loading DLLs is disabled as it's a safety issue in the Rust sense. There's an unsafe constructor which lets you specify that loading DLLs is ok. Instead of: Lua::new() // initialize with relatively safe defaults use: Lua::unsafe_new_with_flags(
StdLib::ALL_NO_DEBUG, // Load all Lua standard libraries apart from debug
InitFlags::DEFAULT - InitFlags::REMOVE_LOADLIB, // Allow loading binary libraries
) Other default flags are I will leave this issue open until the documentation has been improved. As to the segfault, that's concerning. When you say "running the script", does that mean something that uses |
I replaced all instances of
Everything works fine again if I reinstall Lua. So, it seems moonfltk doesn't want to use the builtin Lua for some reason. Not that big of a deal, tho. The segfault only happened with builtin v0.18 and below, I have not seen it so far with v0.19. |
Oh. That sounds to me like moonfltk.dll is linked to a lua.dll - so even if you're using the builtin Lua it'll still link to that. The builtin one should be statically linked with the executable using rlua, so it could be that in this case you end up with two Lua interpreters linked in, which sounds like it could be related to your segfaults on 0.18. In principle I presume it'd be possible for the builtin Lua to be turned into a DLL instead of a static library, which might work better in this case. |
The simplest option is probably for me to stick with |
I think I've since found out a way to use the builtin Lua - the executable needs to export symbols. See #273 (comment) . |
As the changes needed are in applications, I think this issue can be closed. |
I use MSYS2 UCRT64 on Win 10, and I rely on MoonFLTK as part of a package I am working with. MoonFLTK gets compiled into a DLL, and is loaded via
fl = require("moonfltk")
in my script. With rlua v0.18.0, andsystem-lua54
, everything works fine. This is what I have in my Cargo.toml:However, I changed the version to v0.19.4, and it doesn't work anymore:
I now get the following error when I try to execute the script via rlua:
Looking at the paths, it's clear that v0.19 somehow altered how Lua resolves library files. This happens whether I use
system-lua54
orbuiltin-lua54
. With rlua v0.18.0, if I change therequire
to something random likemoonfltkzzz
, I get this message instead :The problem is present in all 0.19.x versions. The system interpreter was left unchanged during all tests.
If I try v0.18.0 with
builtin-lua54
, I get a segfault when running the script, which is why I originally picked the system interpreter.The text was updated successfully, but these errors were encountered: