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
Unable to find .so files in .love file
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Unable to find .so files in .love file
Löve is love, Löve is life.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Unable to find .so files in .love file
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:
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
Code: Select all
local content = love.filesystem.read("path/to/library.so")
love.filesyste.write("library.so", content)
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Unable to find .so files in .love file
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.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:
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 gameCode: Select all
local content = love.filesystem.read("path/to/library.so") love.filesyste.write("library.so", content)
After you have copied the file require should work as expected
Löve is love, Löve is life.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Unable to find .so files in .love file
Does it change if you run it with the --fused flag?
From your command line
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Unable to find .so files in .love file
Running it via terminal works fine, regardless of the --fused flag.Positive07 wrote:Does it change if you run it with the --fused flag?
From your command lineCode: Select all
love yourgame.love --fused
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.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Unable to find .so files in .love file
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
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Unable to find .so files in .love file
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.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Unable to find .so files in .love file
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?
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Unable to find .so files in .love file
The library is numlua. I built it using luarocks as described in the readme.md.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?
Löve is love, Löve is life.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Unable to find .so files in .love file
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
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests