Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin/Android: dlopen liblua53.so fails #53

Closed
MichaelSB opened this issue Jul 22, 2019 · 12 comments · Fixed by NLua/lua#6
Closed

Xamarin/Android: dlopen liblua53.so fails #53

MichaelSB opened this issue Jul 22, 2019 · 12 comments · Fixed by NLua/lua#6

Comments

@MichaelSB
Copy link

We're using KeraLua/NLua with Xamarin/Android and our application fails to start since KeraLua Version 1.0.4 at least. The error we get is (name of app obfuscated):

07-22 13:26:16.210 D/Mono (22457): DllImport attempting to load: 'liblua53.so'.
07-22 13:26:16.214 D/Mono (22457): DllImport error loading library './liblua53.so': 'dlopen failed: cannot locate symbol "fseeko64" referenced by "/data/app/myapp/lib/arm64/liblua53.so"...'.
07-22 13:26:16.215 D/Mono (22457): DllImport error loading library './liblua53.so': 'dlopen failed: cannot locate symbol "fseeko64" referenced by "/data/app/myapp/lib/arm64/liblua53.so"...'.
07-22 13:26:16.215 D/Mono (22457): DllImport error loading library '/system/lib/liblua53.so': 'dlopen failed: library "/system/lib/liblua53.so" not found'.
07-22 13:26:16.215 D/Mono (22457): DllImport error loading library '/system/lib/liblua53.so': 'dlopen failed: library "/system/lib/liblua53.so" not found'.

It works on selected devices (eg Nexus 5x), but fails for most. I think it might be related to android/ndk#364 in one way or another.

@MichaelSB
Copy link
Author

Looks like re-defining a few things in src/liolib.c fixes this for us. I added

#define l_fseek(f,o,w) fseek(f,o,w)
#define l_ftell(f) ftell(f)
#define l_seeknum long

in line 131, which sets l_fseek to fseek unconditionally. This gives a few warnings about redefined macros in the build. Of course this is an ugly "fix". But it might help to fix this in a proper way. Until then, we can use a patched version of liblua53.so in our app.

@viniciusjarina
Copy link
Member

You will need to use platform >= 24.
Lua 5.3 added support to large files (>4gb) to in order to use it you will need to bump you Android Platform
https://github.com/NLua/lua/blob/master/android_build/jni/Application.mk#L2

@MichaelSB
Copy link
Author

We build our app with targetSdkVersion=27, but must support Android 4.1.x (minSdkVersion=16) still. Most users of our app are using Android 6.x. If I understand all of this correctly, any KeraLua/NLua that uses Lua>=5.3 will only run on Android>=7.0? If so, we will have to use a patched version without large file support.

@viniciusjarina
Copy link
Member

I've enabled the LUA_USE_POSIX for Android, if we drop that probably should work if you build from source, you don't need to re-define Lua source code already fallback to the ISO-C definitions if LUA_USE_POSIX Android NDK is pretty bad, and they have added to latest POSIX libraries only in the past releases. I can try to rollback to a older version, but Android 4.1 is too old 😭

@MichaelSB
Copy link
Author

No worries :) I did some changes to Android,mk and Application.mk in our fork (https://github.com/MichaelSB/lua/tree/master) and this seems to do the job without changing the source of lua. Our app is B2B running on pretty expensive devices, so we are forced to support ancient versions of Android forever. I'm closing this, it's solved for us. Many thanks for your feedback, it pushed me in the right direction :)

@viniciusjarina
Copy link
Member

@MichaelSB do you mind share you solution? I can try to bump to official NLua nuget this way you could consume from NuGet (and this may benefit other Xamarin.Android users).

@MichaelSB
Copy link
Author

No, not at all. Everything we changed is in the fork mentioned above and in https://github.com/MichaelSB/KeraLua for the KeraLua-Changes: lua submodule pointing to our lua and I bumped the version number in AssemblyInfo.cs today to make VS2019 shut up about some conflict we got. Feel free to use (and/or change) whatever you want. I'd be very happy, if we could use an official package again some time in the future :)

@viniciusjarina
Copy link
Member

Thank you, I think worth remove the large file support in order to support a more broad base of Android versions.

@MichaelSB
Copy link
Author

I think so too. I can't imagine anyone running scripts this large on phones :) We sure don't. Our scripts are a few hundred lines max. When we started our app, I was very happy to find this package. I'm a fan of lua since ages and being able to customize our app with lua is the best thing since sliced bread. When I'm able to give at least something back, I'm more than happy to do so.

@viniciusjarina
Copy link
Member

The large file support is not for the scripts, is for the io library. if you use io.open to read a binary file.

@MichaelSB
Copy link
Author

Ah ok, thanks for the clarification :) You see, I have no idea what I did here :)

@MichaelSB
Copy link
Author

Great! Many thanks :)

@viniciusjarina viniciusjarina transferred this issue from NLua/NLua Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants