Hi, I want to use C/C++ code in my Android module ...
# kotlin-toolchain
v
Hi, I want to use C/C++ code in my Android module with Kotlin Toolchain. With Gradle I'd use
externalNativeBuild
+ CMake, but I don't see an equivalent in Kotlin Toolchain.
a
Hi @Vivek Could you please share more details? Why do you need to use C/C++ code? What are you writing if it's not a secret (it would help us to prioritize better) Unfortunately we don't support that yet The only thing you can do is to put binaries according to the layout like described here: kotlin-toolchain.org/dev/user-guide/product-types/android-app?…#…
jniLibs
as a non-convenient workaround
v
Thanks for the clarification! I'm working on a code editor/IDE for Android (Multiplatform in future), and I'd like to use native code for some performance-sensitive functionality and libraries (terminal pty) that are already written in C/C++, but the main issue is: I need to compile native code for Android as part of the project build, rather than committing prebuilt
.so
files. For example, I'd like to have something roughly equivalent to:
./kotlin build
=> compile native code with the Android NDK/CMake =>produce the ABI-specific
.so
files => package them into the Android app The
jniLibs
workaround is useful for now, but it makes development awkward because the native build has to be handled separately. I'm mainly asking because native/NDK support would be very useful for projects like mine. Is this something that could fit into the roadmap, perhaps as a generic way to define native build tasks and make the Android
build
depend on them?
a
Were you planning to use the same libraries for the iOS app in future?
Is this something that could fit into the roadmap
We don't have the roadmap yet for the period after October, so that's useful input that you provided I'll take that into account during the planning/roadmap building event
v
Yes, potentially. The main reason I'm looking at native code is for the Android version right now, but some of the core/native functionality could also be useful on iOS in the future. Ideally I'd like to keep the native part portable where practical, rather than maintaining completely separate implementations for each platform. Thanks for taking the feedback into account for the roadmap. Native build support would be really useful for projects like this, especially if it could eventually cover C/C++ and Rust and integrate with the platform build/package process.
a
I created an issue for you to track, feel free to add more details if you want
❤️ 1