Decoding Error while loading external native library (DLL)

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Corralx
Prole
Posts: 4
Joined: Tue Jan 22, 2013 3:35 pm

Decoding Error while loading external native library (DLL)

Post by Corralx »

Hello everyone, i'm new to Love2D and i'm experimenting with it, to understand its capabilities.
I've written a library (DLL) to analyze audio tracks, and i would like to use it in Love2D.
Therefore i need to load a native library in lua.

I've written an empty lua wrapper and an empty Love application to try out the loading of native library in Lua.
However after the library is loaded (i'm sure Love actually finds and tries to load the library), it prints me a "Decoding Error: Not enough space" error.
As far as i can tell by looking in this forum, is a string encoding related issue.

I've already looked at the source code for the AudioIn project in this forum (viewtopic.php?f=5&t=2076), even though i didn't find out why my version isn't working.

Has anyone done this succesfully before?
I've attached the lua source file the tries to load the library, and the C++ source of the DLL.

Thx, Corralx

EDIT:
I've tried this with others Lua framework and plain Lua code, and it works as expected.
Maybe there is something broken/not supported in Love?
Attachments
dllmain.cpp
(904 Bytes) Downloaded 152 times
main.lua
(119 Bytes) Downloaded 142 times
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Decoding Error while loading external native library (DL

Post by Boolsheet »

That is indeed an error message from the UTF-8 library. Considering we're dealing with the module searchers/loaders here, I'm guessing something errors and the error message contains a path with non-ASCII characters from one of the Lua loaders. love.graphics.print in the error handler doesn't take kindly to that and blows up. Look at stdout of LÖVE to see both error messages. Do you have any exotic paths? ;)

The LÖVE binary loader looks in two places only. For Windows, it's '%APPDATA%/LOVE'. Or, if the game is in release mode, then it also looks in the save directory (making it '%APPDATA%/<game identity>'). The LÖVE loaders ignore package.(c)path. You can also use the Lua binary loader if you're more comfortable with that, LÖVE doesn't remove it.

Your LuaWrapper module works for me. I have a two comments.

The real predefined macro is _WIN32 with an underscore. I think Visual Studio sets up both by default in the project settings, but only the one with the underscore is actually predefined by the compiler. If VS didn't set it up, you chose another compiler or forced exporting in another way, then your function most likely didn't get exported. (Edit: If you say it worked for other things, then this is probably irrelevant to you)

Why do you use the deprecated luaL_openlib instead of luaL_register? As far as I can tell they are the same (if compatibility mode is enabled), but it will be less confusing if you use the new one.
Shallow indentations.
Corralx
Prole
Posts: 4
Joined: Tue Jan 22, 2013 3:35 pm

Re: Decoding Error while loading external native library (DL

Post by Corralx »

Thanks for the reply.
Starting from the bottom...

I put that example togheter really fast, but you're right. The default macro is _WIN32.

For the luaL_openlib question, i've never written a wrapper for lua before, and in the beginning i was using lua 5.2 which deprecated luaL_openlib in favor of luaL_register.
Then i noticed Love actually uses lua 5.1 so i switched to that version and i supposed luaL_openlib was the standard way of loading a library there (actually i was wrong) :3

Anyway, i still didn't managed to get it work on my system.
Probably i'm doing something wrong with the path.
I have placed my LuaWrapper.dll in the LOVE directory (C:\Program Files (x86)\LOVE).
Is this the right place?
If i don't place it there, Love gives me a "Module LuaWrapper not found" error, so i guess that at least Love found the library and tries to load it.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Decoding Error while loading external native library (DL

Post by Boolsheet »

Corralx wrote:I have placed my LuaWrapper.dll in the LOVE directory (C:\Program Files (x86)\LOVE).
Is this the right place?
That will make the Lua binary loader load it (if package.cpath points to it). There should be no differences if the LÖVE or the Lua loader loads it, I think.

Try it in '%APPDATA%\LOVE'.

And when in doubt, upload the DLL. :P
Shallow indentations.
Corralx
Prole
Posts: 4
Joined: Tue Jan 22, 2013 3:35 pm

Re: Decoding Error while loading external native library (DL

Post by Corralx »

Uhm, if i place the LuaWrapper.dll inside the %APPDATA%\LOVE folder, it says "Module LuaWrapper not found".
My %APPDATA% variable points to "C:\Users\<My Username>\AppData\Roaming", and love doesn't seems to search in there to load the binaries.
Anyway i've attached the DLL i'm currently using. :crazy:
Attachments
LuaWrapper.zip
(21.78 KiB) Downloaded 129 times
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Decoding Error while loading external native library (DL

Post by Boolsheet »

Huh, that DLL works for me.

Just to rule out something else: you installed the 32-bit version, right? I think the LÖVE installer installs both versions in 'Program Files (x86)', sadly.
Corralx wrote:My %APPDATA% variable points to "C:\Users\<My Username>\AppData\Roaming", and love doesn't seems to search in there to load the binaries.
How did you check that?
Shallow indentations.
Corralx
Prole
Posts: 4
Joined: Tue Jan 22, 2013 3:35 pm

Re: Decoding Error while loading external native library (DL

Post by Corralx »

Oh my god :ehem:
I actually had the 64 bit version installed.
I feel like an idiot... I have just installed the 32 bit version and everything works........
This morning when i installed love i didn't think that i would need to link a 32 bit DLL :(

Thx for the help :ultrahappy:
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests