Page 1 of 2
Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 8:46 pm
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
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 8:56 pm
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
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 9:11 pm
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.
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 9:15 pm
by Positive07
Does it change if you run it with the --fused flag?
From your command line
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 9:19 pm
by ThePC007
Positive07 wrote:Does it change if you run it with the --fused flag?
From your command line
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.
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 9:26 pm
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
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 9:34 pm
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?
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 10:09 pm
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?
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 10:14 pm
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.
Re: Unable to find .so files in .love file
Posted: Fri Jun 10, 2016 10:20 pm
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