-
Notifications
You must be signed in to change notification settings - Fork 266
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
[question] Please, am I missing something? #1508
Comments
For more context, this is the app project I want to run, and this is the bug I have run into, thus the error above. On a machine I am using(running Ubuntu 20.04), using an x86 android emulator running Android 9, I still run into the same error, but a different symbol not being found. Thanks for your time. |
demangler.com says that's |
Seems that the exception classes in |
OK. :). In the build_rust.sh script, libc++_shared.so is copied in order to be used. Please, do you suggest trying out libc++? |
In the bug you linked I see:
I'm not sure what build_rust.sh is (I haven't had time to read through the project you linked, just the bug). If you can upload the broken APK it'll probably be pretty obvious what's wrong, given the above comment. |
Actually, I double-checked it, and now the .so is part of the apk, but still running into the original issue. |
By the way, this is the script: here |
Can you upload the APK? |
OK. |
I can't upload the apk due to GitHub file type support. Sorry. |
Rename it .txt |
$ readelf -dW lib/x86/librgb.so
Dynamic section at offset 0xc4e7dc contains 30 entries:
Tag Type Name/Value
0x00000003 (PLTGOT) 0xc4fd1c
0x00000002 (PLTRELSZ) 1456 (bytes)
0x00000017 (JMPREL) 0x2d55c
0x00000014 (PLTREL) REL
0x00000011 (REL) 0x2b4c
0x00000012 (RELSZ) 174608 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffa (RELCOUNT) 21675
0x00000006 (SYMTAB) 0x1cc
0x0000000b (SYMENT) 16 (bytes)
0x00000005 (STRTAB) 0x151c
0x0000000a (STRSZ) 4704 (bytes)
0x6ffffef5 (GNU_HASH) 0x277c
0x00000001 (NEEDED) Shared library: [liblog.so]
0x00000001 (NEEDED) Shared library: [libstdc++.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x0000001a (FINI_ARRAY) 0xc1a100
0x0000001c (FINI_ARRAYSZ) 8 (bytes)
0x00000019 (INIT_ARRAY) 0xc4f7d8
0x0000001b (INIT_ARRAYSZ) 4 (bytes)
0x0000001e (FLAGS) BIND_NOW
0x6ffffffb (FLAGS_1) Flags: NOW
0x6ffffff0 (VERSYM) 0x2824
0x6ffffffc (VERDEF) 0x2a90
0x6ffffffd (VERDEFNUM) 1
0x6ffffffe (VERNEED) 0x2aac
0x6fffffff (VERNEEDNUM) 4
0x00000000 (NULL) 0x0 You included libc++_shared.so but you didn't actually link against it.
But you're definitely using it. Whatever build system built librgb.so (cargo?) isn't using You're either missing a flag when building that library (and the build system isn't protecting you from that like it ought to) or the build system that built it is just wrong. The peculiar part is that it's pretty clearly using the headers from libc++, it's just never linking it. Maybe the libc++ dependency is coming in from a static library being linked into librgb.so, and librgb.so doesn't know about that? |
I am manually building it using clang++ directly. |
Are you using an old NDK? |
By the way, I am copying libc++_shared from Sdk/ndk/20.1.5948944/sources/cxx-stl/llvm-libc++/libs/x86/ |
NDK v. 20.1.5948944 |
And then immediately clobbering it with something built by cargo: https://github.com/rgb-org/rgb-sdk/blob/a61df14e1c4e3eab739cffef4034187e756d89ce/bindings/android/build_rust.sh#L28-L29 |
Please, I don't understand. Please, do you suggest I remove the second line(the line that copies the lib)? |
That's at least one of your problems. The problem with cargo is another, and I haven't figured that one out yet. |
Whether you need to the first line, the second line, or both and you need to rename one of the libraries, I have no idea. I'm not sure what these libraries are, all I know is that you're building one correctly and then overwriting it with one that's built incorrectly. |
OK, I see. |
I will have to test the two cases to be sure, then. |
Please, can you go into more detail about the problem with cargo?(I hope I am not asking too much :) ) |
I will once I understand it. It's building the broken library, that's all I've figured out so far. The flags you're setting when calling cargo are certainly wrong: https://github.com/rgb-org/rgb-sdk/blob/a61df14e1c4e3eab739cffef4034187e756d89ce/bindings/android/build_rust.sh#L16. See https://developer.android.com/ndk/guides/other_build_systems. You've passed But if I correct them (by deleting them) CMake (idk how or why cmake fits into this) fails to configure the target correctly, and also can't find the linker. Haven't figured that one out yet. You've also mixed and matched toolchains: https://github.com/rgb-org/rgb-sdk/blob/a61df14e1c4e3eab739cffef4034187e756d89ce/bindings/android/build_rust.sh#L11 is using API 26, but elsewhere you've used API 21. idk if that's a part of the problem but there's definitely no reason to do that. Where is any of the cargo for android behavior documented? I had to |
tl;dr your dependencies haven't been ported to Android. This isn't a valid Android CMake build. It doesn't follow https://developer.android.com/ndk/guides/cmake or https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android. No
That happens when building zeromq, on of your dependencies. https://github.com/LNP-BP/zeromq-src-rs/blob/fix/cmake/src/lib.rs seems to be what's calling CMake, and it's wrong for Android. The CMake crate is correct (https://github.com/alexcrichton/cmake-rs/blob/c87b73114d3d4b496018c0c5b8200d0274821a6e/src/lib.rs#L383-L391), but the zeromq-rs crate is not setting it up properly. The zeromq build doesn't appear to be configurable: https://github.com/LNP-BP/zeromq-src-rs/blob/e95a4e68136a6897d61c936622933bf259ebdd7f/src/lib.rs#L215-L335 |
btw, a reduced (I removed most ABIs for debugging) version of your build script that fixes the obvious problems:
|
Thanks a lot 🙏 |
Please, what about Swig, since it is used to generate the JNI bindings?(Because I dont see it in the reduced version) |
That part was working fine, you were just clobbering the output. Don't do that and it was building fine. |
OK. Thanks very much. I will try these out more extensively, and get back to you 🙏 👍 |
Hello again. I tried and this time, it still crashed with the following error:
|
Right now, I want to add a CMake toolchain file. Please, @DanAlbert , should I add it to the library project or to the app project? |
You don't add it anywhere, you use the one from the NDK. You'd need to fix the zeromq crate I linked before. |
Please, do you have any pointers on how to fix it?(Since I am not very experienced) |
#1508 (comment) points to the broken sources, broken functions within those sources, and the docs that explain how to use cmake correctly. |
OK, thanks very much. Did not pay close attention to the comment. |
So, I will have to basically fork the zeromq crate, apply the corrections, and test it out. |
Actually, it looks like the CMake crate will accept a toolchain file from the environment: https://github.com/alexcrichton/cmake-rs/blob/c87b73114d3d4b496018c0c5b8200d0274821a6e/src/lib.rs#L727-L731 |
So does it mean that I just need to create a toolchain file and point to it in the script? |
It looks like it's because the project is stuck on an ancient version of the cc crate that doesn't work with the NDK. You need to update those dependencies. Not really anything to do with the NDK, so you'll need to take those bugs to the project owner. |
Please, which project? zero-mq? |
|
Thanks, I saw. I'll report it then. :) |
I think I should not also forget to pass in the swig C++ generated file as an argument to clang in the script. |
Hello everyone. I want to use a Rust library on Android. I am using Swig to generate JNI bindings and I am generating the shared library manually using a script(the clang toolchain). I am also manually copying the generated AAR into the app project. However, when running the app it shows the following error :
I have checked the AAR, SO files, and the symbol it complains about is present. Also, the function for which it can't find the implementation is also present. I have tried some fixes, all to no avail. I hope someone can help me.
The text was updated successfully, but these errors were encountered: