Overview
The C-Interop feature of the Kreate Gradle plugin provides a fully automated pipeline for bridging Kotlin/Native multiplatform projects with native Rust libraries. When enabled, Kreate orchestrates every step — from initializing a Rust project via Cargo, adding dependencies, compiling for multiple native targets, generating C headers with cbindgen, producing Kotlin/Native .def files, and wiring the resulting static libraries into your Kotlin Multiplatform build — all without manual setup.
Pipeline Overview
The C-Interop pipeline consists of six ordered Gradle tasks that run automatically before any Kotlin/Native compilation:
Step | Task | Description |
|---|---|---|
1 |
| Creates a new Rust library project with |
2 |
| Adds |
3 |
| Appends |
4 |
| Generates a |
5 |
| Runs |
6 |
| Writes the Kotlin/Native |
After step 6 completes, all CInteropProcess tasks automatically depend on kreate-c-interop-definitions, so your normal build or assemble invocation drives the entire chain.
Enabling C-Interop
C-Interop is disabled by default. Enable it inside your module's build.gradle.kts within the kreate extension block:
Once enabled, all six pipeline tasks are registered automatically and execute in order before the first CInteropProcess task runs.
Next Steps
Configuration Reference: DSL reference and all available options
Gradle Tasks: Details on the individual pipeline tasks
Examples: Practical examples and usage patterns
Troubleshooting: Common issues and solutions
Generated Project Layout
After the pipeline runs, the following structure is created inside your Gradle module:
C-Interop Package Name
By default, the Kotlin package under which the native symbols are exposed is derived from the Gradle project group and the (lowercased) project name:
Override it with packageNameOverride:
Cargo Command Resolution
On macOS, Kreate looks for cargo at ~/.cargo/bin/cargo (the default rustup install path). On all other platforms, it simply invokes cargo from the system PATH.