lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Am 26.12.16 um 10:04 schrieb Marc Balmer:

>> I try to preserve the usual Lua semantics for Android which means
>> building dynamic libraries. So as you identified, I always use the lib
>> prefex on Android. But this isn't just for System.loadLibrary(), but
>> affects what Android does when it encounters your .apk. Android
>> automatically extracts out the lib*.so files into a special directory
>> so it is possible to use them. It ignores everything else. CPATH alone
>> wouldn't help you since the files are not directly on the filesystem,
>> but archived inside the APK.
> So it _only_ extracts lib*.so files, and not *.so, right?  In that case
> I will have to prefix my Lua modules with 'lib' which is no big deal.
> Do you know the path where it extracts lib*.so files to?  If that is
> known and constant, it could be possible to doctor CPATH so that require
> loads those using dlopen().  Certainly something I want to give a try.

I found out (by googling and a bit of trial and error) that lib*.so
files get extracted to /data/data/<app id>/lib/.

So setting the LUA_CPATH_DEFAULT actually works, e.g. my app id is
ch.msys.lua, so I have the following in my luaconf.h file:

#define LUA_CPATH_DEFAULT "/data/data/ch.msys.lua/lib/lib?.so"

With this, I can now 'require' any dynamically linked Lua module that I
put in to my software.