How to use Lua FFI on Android with custom .so's Packaged on the .love

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
mhxiy
Prole
Posts: 3
Joined: Wed Dec 11, 2024 7:30 pm

How to use Lua FFI on Android with custom .so's Packaged on the .love

Post by mhxiy »

I've used android NDK to make compile shared libraries which I intend to run on Love2d. They work fine and their code is fine. The problem comes into play because I don't know proper way to use ffi.load argument, I've tried the name of the library, no extension, with, with source path and putting it on Documents and linking it through that but that requires that app to have the xml external storage permissions and using the SAF which looks like it'd require me to put Java-lua bridge which I'd like to avoid.

My goal is to have a way to include in my project a selection of .so libraries and be able to use them from the app in an android environment. Has anyone figured this out or have a clever work-around? Any project links with demonstrations would be a nice but not essential bonus. Thanks in advance.
RNavega
Party member
Posts: 385
Joined: Sun Aug 16, 2020 1:28 pm

Re: How to use Lua FFI on Android with custom .so's Packaged on the .love

Post by RNavega »

There's this:
viewtopic.php?p=260947#p260947
But I don't like the way that it creates a copy of the library that'll survive the app uninstall process.

If you find a solution, do post it in here to help others.

Edit: you could also try creating a Lua C module with some functions that glue your desired library, if it's open source. Then instead of FFI.load() you'd use Lua's require(), calling your glue functions that internally call the library.
Something like this:
- https://github.com/Seng3694/CLuaModuleExample
- https://www.lua.org/pil/26.2.html

Edit 2: and also this: viewtopic.php?p=260902#p260902
(The Discord link is on the LÖVE homepage, Community section: https://love2d.org/)
mhxiy
Prole
Posts: 3
Joined: Wed Dec 11, 2024 7:30 pm

Re: How to use Lua FFI on Android with custom .so's Packaged on the .love

Post by mhxiy »

Thanks so much for the link! I'd thought about doing just that as I was learning about how android handled data but did not have the confidence or technical knowledge to go through with it. I'll definitely be trying this soon. Thanks so much ^^
Dreamweaver
Prole
Posts: 1
Joined: Mon Dec 23, 2024 5:15 pm

Re: How to use Lua FFI on Android with custom .so's Packaged on the .love

Post by Dreamweaver »

RNavega wrote: Thu Dec 12, 2024 9:48 am (The Discord link is on the LÖVE homepage, Community section: https://love2d.org/)
It appears that link is broken, as it tells me it is expired when I click it.
Post Reply

Who is online

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