-
Notifications
You must be signed in to change notification settings - Fork 36
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
Android build #142
Comments
Hi @kocho1984, However, there is no reason why SIL Kit shouldn't run on Android with little to no changes (it is really portable). Have you already tried building SIL Kit using Android NDK? can you shed some more light on the use cases involving Android? |
@MariusBgm, Regarding use case in Android: basically it is to test communication (send/receive) between two apps using SIL Kit. |
@MariusBgm, I was able to build libSilKit.a with NDK. Due to the fact that SIL Kit uses exceptions, RTTI (for dynamic_cast), and has some cases where destructor is not virtual even if other methods are virtual, I had to enable following build options, as default compiler options for Android don't allow e.g. using exceptions. However, when I'm trying to build a lib which is trying to use functionality from libSilKit.a, I get tons of linker errors which seem to be related to STL, e.g. shared_ptr, basic_string, etc. Some examples:
You mentioned that you don't have an official Android build in your CI, but have you tried building it locally by any chance, or encountered similar linker errors in the past when working on Android builds? |
@kocho1984 can you share the complete linker command line that cmake used for linking? I suppose the |
@MariusBgm ,
Or you ask for the linker command used to build a lib which uses libSilKit.a? |
@kocho1984 thanks for the feedback. I can see that SilKit builds cleanly. However, you are using the static library type. On your application side, where the linking fails, you might lack linking against libc++_shared.so. |
@MariusBgm, thank you for quick response. Static SilKit.a is intentional. |
@kocho1984 no, I mean your test application that links against the libSilKit.a.
you need to link your own library ( or test application for that matter) using --whole-archive and properly link the application where you use your own library against the stdc++ library. |
@MariusBgm There are following linker errors. |
@kocho1984 I reproduced your issue locally. It's caused by our use of the linker script
|
My shared library that relies on the SilKit library is an Android platform library built using the Android platform's Soong build system (which uses blueprints: Android.bp files rather than CMakeLists.txt). This caused linker errors because the Android platform's libc++ doesn’t include This post on android-ndk forum also confirms that build with NDK should be used only for apps, not for libs. |
@kocho1984 thanks for the feedback. Writing your own Android.bp blueprint files should be straight forward though. However, out of curiosity: SilKit exposes a stable C ABI, so if the libc++ is statically linked, it might work.
The |
SilKit is big project with more than 1000 cpp files and more than 70 CMakeLists.txt files (including its dependencies). That means that all of those CMakeLists.txt should be rewritten as Android.bp. I believe it is complex and time-consuming task.
Thank you, I will probably check it. However I think that mixing different libc++ (NDK and platform in this case) is risky and usually not recommended because it may lead to unpredicted behavior and runtime errors. As it is also stated in the android-ndk group, building all the components on the platform is much safer because one libc++ is used in such case. |
@MariusBgm
This line contains both Do you know maybe how that command should look in case I would like to build SilKit as a static lib? |
Yes, it tells the linker to contain the whole archive named
A static library is just an archive of object files -- the linker doesn't resolve symbols, and thus adding |
@kocho1984 if you want to discuss this further or how to integrate SIL Kit into different build systems, feel free to contact me using my work emailadress which you can find in the git log. |
Hello,
Does SIL Kit support build for Android? I mean if it is possible to build SIL Kit as a static or shared lib and use it by the application written in C++ in Android?
If not, do you have maybe any hints how could this be achieved?
The text was updated successfully, but these errors were encountered: