This project provides a unified and automated way to include and call native C code from Kotlin Multiplatform (KMP).
The goal is to allow developers to maintain a single C/C++ codebase (e.g., src/native/c) and automatically wire it up to:
- Android: Via JNI (Java Native Interface) using CMake.
- iOS / Native: Via Kotlin/Native CInterop.
- Desktop (JVM): Via JNI (shared library).
- 🚀 Zero Glue Code: Automatically generate JNI wrappers and Kotlin bindings.
- 🛠 Unified Source: All C code lives in
native/c. No more multiple glue layers. - 📱 Multi-Platform: Support for Android, iOS, JVM, and Native targets out-of-the-box.
- ⚙️ Gradle Integrated: Custom
generateJnitask fits seamlessly into your build workflow.
native/c: Contains your C source code (mylib.c,mylib.h).shared: The KMP library, wired to use the generated bindings.plugin: The Gradle plugin module containing the automation logic.docs: Full documentation set for users and developers.
// native/c/mylib.h
int add_numbers(int a, int b);./gradlew :shared:assembleimport com.abyxcz.cbindingkmp.shared.generated.add_numbersJNI
val result = add_numbersJNI(10, 20)For more details, see the Getting Started Guide.
- Introduction
- Getting Started
- Developer Guide
- Architecture & Automation Logic
- API Reference
- Contributing
This project is licensed under the MIT License - see the LICENSE file for details.