Unable to find .so files in .love file

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.
User avatar
ThePC007
Prole
Posts: 36
Joined: Sat Jan 30, 2016 3:00 pm
Contact:

Unable to find .so files in .love file

Post by ThePC007 »

My game is using a shared library (.so) file in order to create a C-bind. It works just fine when I run it directly from the directory I saved it to, however when I create a .love file and run it by double-clicking it (not through the terminal), I cannot load it using the "require" function, as it just crashes saying that it cannot find the .so file. love.filesystem.exists() does, in fact, return true, though, so it is definitely there. I am aware that the problem can be fixed by dropping the .so-file into usr/local/lib/lua/5.1 or into the home directory, however, I'd like to have some way of delivering the .so-file together with my game, rather than expecting the user to install it himself. Is there any way I could do that?

- ThePC007
Löve is love, Löve is life.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Unable to find .so files in .love file

Post by Positive07 »

LÖVE supports loading .so files or .dll files from the save directory, try copying your file from inside your .love file into the save directory with something like:

Code: Select all

local content = love.filesystem.read("path/to/library.so")
love.filesyste.write("library.so", content)
This may take a while and you should check if the library is not already present in the save directory so that you don't copy every time you open your game

After you have copied the file require should work as expected
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
ThePC007
Prole
Posts: 36
Joined: Sat Jan 30, 2016 3:00 pm
Contact:

Re: Unable to find .so files in .love file

Post by ThePC007 »

Positive07 wrote:LÖVE supports loading .so files or .dll files from the save directory, try copying your file from inside your .love file into the save directory with something like:

Code: Select all

local content = love.filesystem.read("path/to/library.so")
love.filesyste.write("library.so", content)
This may take a while and you should check if the library is not already present in the save directory so that you don't copy every time you open your game

After you have copied the file require should work as expected
That doesn't really seem to work. I still get the same exact error, even though the shared library is now in the save directory.
Löve is love, Löve is life.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Unable to find .so files in .love file

Post by Positive07 »

Does it change if you run it with the --fused flag?

From your command line

Code: Select all

love yourgame.love --fused
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
ThePC007
Prole
Posts: 36
Joined: Sat Jan 30, 2016 3:00 pm
Contact:

Re: Unable to find .so files in .love file

Post by ThePC007 »

Positive07 wrote:Does it change if you run it with the --fused flag?

From your command line

Code: Select all

love yourgame.love --fused
Running it via terminal works fine, regardless of the --fused flag.
EDIT: Alright, it seems that running it from the terminal without the fuse flag only works, because the .love was located in the same folder that I kept all the source files in and it just used the .so-file which was naturally located in that folder. I moved it to a different location and running it without the --fused flag results in an error, while running it with it works fine.
Last edited by ThePC007 on Fri Jun 10, 2016 9:29 pm, edited 1 time in total.
Löve is love, Löve is life.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Unable to find .so files in .love file

Post by Positive07 »

Well that is weird, but you could distribute your .love with a script to run it as --fused

Also your .so file is compiled for the specific libraries in your operating system, they may not work on other systems if the exact same dependencies are not available so your user may end up having to compile the library himself
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
ThePC007
Prole
Posts: 36
Joined: Sat Jan 30, 2016 3:00 pm
Contact:

Re: Unable to find .so files in .love file

Post by ThePC007 »

Well, the thing is, I actually wanted to release my game on Android, so creating a script to run it would be far from optimal. Also, regarding your last sentence, would that mean I'd have to somehow compile the .so file on an Android system?
Löve is love, Löve is life.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Unable to find .so files in .love file

Post by Positive07 »

Well that is WAY harder, first your library needs to be compiled with the Android NDK and built into LÖVE itself, check how the repository compiles Lua Sockets for example on how to do this, it's not that hard but in no way will you be able to use a .so file

Also if your library access some stuff not available on Android or uses a system dependant library you may need to change some stuff.

Could you provide more information? What is this library you need? How have you compiled it? What are the dependencies?
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
ThePC007
Prole
Posts: 36
Joined: Sat Jan 30, 2016 3:00 pm
Contact:

Re: Unable to find .so files in .love file

Post by ThePC007 »

Positive07 wrote:Well that is WAY harder, first your library needs to be compiled with the Android NDK and built into LÖVE itself, check how the repository compiles Lua Sockets for example on how to do this, it's not that hard but in no way will you be able to use a .so file

Also if your library access some stuff not available on Android or uses a system dependant library you may need to change some stuff.

Could you provide more information? What is this library you need? How have you compiled it? What are the dependencies?
The library is numlua. I built it using luarocks as described in the readme.md.
Löve is love, Löve is life.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Unable to find .so files in .love file

Post by Positive07 »

Well I don't intend to discourage you but this won't a simple task, you have to include the library and all the dependencies (which are a bunch!) into the love-android-sdl2 project and make the build file compile these as static libraries into the love-android-sdl2 APK, I also recommend to put your game in there too.

Also if for some reason this libraries also have dependencies you will need to compile those too into your project and so on.

If the libraries use features that are system dependant and/or not present in Android and it's NDK then the libraries won't compile and debugging and fixing that can be pretty hard
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 7 guests