Page 1 of 2

Lua 3rd-Party Libraries Not Loading

Posted: Fri Nov 15, 2019 12:19 pm
by mminsel
Hi,

I have the following issue:

I'm running Moho 12 on Win 10.
Moho 12 contains Lua version 5.2 x64 (I think.. as _VERSION returns 5.2 and running prebuild libraries with x32 gave me an dll error).

So I compiled the Lua-socket module linking it against version 5.2.4 x64.
I installed it to a dedicated folder and have set the LUA_PATH and LUA_CPATH variable in my CMD.
When I launch Lua in this CMD everything works.
When I now launch Moho from the same CMD and run the following commands from a tool in Moho it doesn't work:

Code: Select all

http = require("socket.http")
r, c, h = http.request{method = "GET", url = "http://www.google.com"}
Instead it complains saying:
Error loading module: /path/to/cpath/socket/core.dll: The module wasn't found.
I wonder if this is a conflict with the internal Lua version? What Patch version is included in Moho 12 and how can I get the exact version number and possibly the arch (x64/x32)? (_VERSION just gives me 5.2)

If the Lua version matches: Is there any restriction in using third-party dlls in the Moho-Lua?

The LUA_PATH, LUA_CPATH and PATH look correct in Moho.

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Nov 15, 2019 1:50 pm
by mminsel
I actually recompiled it in x32: I don't get the
Error loading module: /path/to/cpath/socket/core.dll: The module wasn't found.
but only the
Error loading module: /path/to/cpath/socket/core.dll:
So the problem persists

Re: Lua 3rd-Party Libraries Not Loading

Posted: Mon Nov 25, 2019 4:58 pm
by mminsel
I switched to version 13 of Moho. What I get is:

With Lua 5.2.4 and 5.2.0 x64 I still get an immediate crash.

with Lua 5.2.3 and 5.2.1 x64: Error: Multiple Lua VMs detected.

Googling this error gave me two possible reasons:

1. The version of Lua is not exactly the same as the one I'm linking against
2. The Moho executable is not linking lua dynamically

So I guess that the latter may be the cause of the issue.

Re: Lua 3rd-Party Libraries Not Loading

Posted: Mon Nov 25, 2019 11:52 pm
by synthsin75
Once upon a time, Moho could find dlls in a modules folder in the scripts folder, but I don't think that functionality has worked since, maybe, v10 or older.
As far as I know, Moho uses Lua compiled in its executable, so even if you get it to find another Lua build, it's always going to find that compiled one as well.

Re: Lua 3rd-Party Libraries Not Loading

Posted: Wed Mar 23, 2022 6:17 am
by Defims
Error: Multiple Lua VMs detected
means moho main program already embeded a lua vm. if you require a dll which embed a lua vm either, error will be throw out.
I think the best solution is expose the lua vm in moho main program for user defined usage.

Re: Lua 3rd-Party Libraries Not Loading

Posted: Wed Mar 23, 2022 7:23 am
by SimplSam
Defims wrote: Wed Mar 23, 2022 6:17 am
Error: Multiple Lua VMs detected
means moho main program already embeded a lua vm. if you require a dll which embed a lua vm either, error will be throw out.
I think the best solution is expose the lua vm in moho main program for user defined usage.
An alternate solution is for LM to upgrade the Moho embedded Lua to 5.4 - which allows multiple VM's.

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Oct 28, 2022 2:32 am
by Rai López
So it was not only me... I've spend several days already trying to make LuaSocket to work with Moho with similar errors like...

Code: Select all

error loading module 'socket.core' from file 'D:\Ramon0\Projects\Animation\Moho Pro\Scripts\Modules\socket\core.dll':
The specified module could not be found.
...in my case, but I thought it had more to do with me not using the exact binaries (I've not been able to find the ones for Lua 5.2.4 64-bit, and I've been testing every other binaries I could have find out there). Although I see now that it surely wouldn't have worked anyway.

What a pity, because it would open a whole new world of scripting possibilities... Really nobody has got to make it work? Even if not with LuaSocket but with any other package? It seems so close, because for the error one could think that at least Moho is correctly accessing the dll file, but then encountering some problem finding the specified module in it.

synthsin75 wrote: Mon Nov 25, 2019 11:52 pm Once upon a time, Moho could find dlls in a modules folder in the scripts folder, but I don't think that functionality has worked since, maybe, v10 or older.
Regarding that, I've found this line in an old changelog:
  • 2012-10-19 - Fixed Bug #25606 - Lua dll modules are now properly loaded from the user scripts/modules folder.
So, in theory, at some point that issue got some attention from devs, but who knows if maybe it wasn't then tested well enough or whatever :cry:

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Oct 28, 2022 2:56 am
by synthsin75
Ramón López wrote: Fri Oct 28, 2022 2:32 am
synthsin75 wrote: Mon Nov 25, 2019 11:52 pm Once upon a time, Moho could find dlls in a modules folder in the scripts folder, but I don't think that functionality has worked since, maybe, v10 or older.
Regarding that, I've found this line in an old changelog:
  • 2012-10-19 - Fixed Bug #25606 - Lua dll modules are now properly loaded from the user scripts/modules folder.
So, in theory, at some point that issue got some attention from devs, but who knows if maybe it wasn't then tested well enough or whatever :cry:
It was working at one time, as I had an eyedropper tool that could pick colors outside of Moho. It used a Lua 5.1 and a custom color picker dll.
I no longer have v11 installed, but I checked, and it doesn't work in v12 or 13.

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Oct 28, 2022 3:16 am
by Rai López
My hopes were dashed then... But at least now I can stop trying, thanks for taking the time of testing and confirming. Sincerely, all that LuaRocks for Windows and everything is totally way over my head, so I've been trying everything that was in my hand for not having to deal with installing it and compiling and all that, and when I was about to do it turns out find this, who knows how much time I would have had to invest for nothing otherwise. Well... let's try to move on then...

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Oct 28, 2022 3:38 am
by Rai López
synthsin75 wrote: Fri Oct 28, 2022 2:56 am I no longer have v11 installed, but I checked, and it doesn't work in v12 or 13.
🤔 But, out of curiosity, did you get similar errors as the ones mentioned above? I mean, do you also have the feeling that Moho/Lua is actually being able to "read" inside the .dll but, for whatever reason, having troubles to find whatever it's needed to find in there? I'm not quite sure where I'm going with this question... I guess the fact that Moho seems to be able to get into the .dll module still gives me some kind of hope? (Even though I just said I was going to move on 🙄).

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Oct 28, 2022 3:54 am
by synthsin75
Ramón López wrote: Fri Oct 28, 2022 3:38 am
synthsin75 wrote: Fri Oct 28, 2022 2:56 am I no longer have v11 installed, but I checked, and it doesn't work in v12 or 13.
🤔 But, out of curiosity, did you get similar errors as the ones mentioned above? I mean, do you also have the feeling that Moho/Lua is actually being able to "read" inside the .dll but, for whatever reason, having troubles to find whatever it's needed to find in there? I'm not quite sure where I'm going with this question... I guess the fact that Moho seems to be able to get into the .dll module still gives me some kind of hope? (Even though I just said I was going to move on 🙄).
Some part of it still seem to work:
Image

If you put the dll anywhere except the modules folder, Moho complains about not finding it.
And this error does seem to involve Moho reading the dll, but I'm not sure I still have the source files to verify that.

EDIT: Nope, that error is just because the dll was written for 32bit. If I launch v12 in 32bit, I get this instead:
Image
...which doesn't seem to be reading anything in the dll.

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Oct 28, 2022 6:11 pm
by Rai López
Argh... OK, I think I kind of resisted to believe it was indeed totally broken, but that's what it seems... Again, thanks for taking the time of testing it and posting all the details.

Maybe if I could write/get a very simple .dll file I'll be able to do some more tests starting from the simplest kind of module calling possible and see, but I feel so lost when it comes to deal with something different than Lua, and more if it involves compiling and such kind of stuff, that I'm not sure till what point that will be possible. Well...

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Oct 28, 2022 6:22 pm
by synthsin75
Yeah, it's been years since I made that dll, and I'd have to relearn everything again.

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Oct 28, 2022 6:47 pm
by Rai López
So you made it from scratch?? I wasn't sure if it would be simply part of a third party library or something... Dude, how I hate it be so easy to forget certain so valuable stuff, but at least you can argue that have passed years, it starts to happen to me from one week to another :lol: ( :( )

Re: Lua 3rd-Party Libraries Not Loading

Posted: Fri Nov 25, 2022 4:42 am
by Defims
synthsin75 wrote: Fri Oct 28, 2022 2:56 am
Ramón López wrote: Fri Oct 28, 2022 2:32 am
synthsin75 wrote: Mon Nov 25, 2019 11:52 pm Once upon a time, Moho could find dlls in a modules folder in the scripts folder, but I don't think that functionality has worked since, maybe, v10 or older.
Regarding that, I've found this line in an old changelog:
  • 2012-10-19 - Fixed Bug #25606 - Lua dll modules are now properly loaded from the user scripts/modules folder.
So, in theory, at some point that issue got some attention from devs, but who knows if maybe it wasn't then tested well enough or whatever :cry:
It was working at one time, as I had an eyedropper tool that could pick colors outside of Moho. It used a Lua 5.1 and a custom color picker dll.
I no longer have v11 installed, but I checked, and it doesn't work in v12 or 13.
WOW, Moho 11 is nice! I wonder how to pass the color value back to Moho in your color picker dll, Is it some code like:

Code: Select all

lua_pushstring(L, "#000");
Is it possible to call other function? like:

Code: Select all

lua_getglobal(L, "CHANNEL_BONE_3");