Kreate v1.2.3 Help

Examples

Minimal Configuration

The simplest possible setup: C-Interop is enabled, and Kreate auto-detects everything else.

kreate { platform { multiplatform { cInterop { enabled.set(true) } } } }

This uses the Gradle project name as the Rust project name, auto-detects the host target, and places all files under <module>/cinterop/.

Custom Name and Directory

Override the Rust project name and the directory where it is created:

kreate { platform { multiplatform { cInterop { enabled.set(true) nameOverride.set("myRustLib") projectDirectory.set(layout.projectDirectory.dir("native")) } } } }

The Rust project is created at <module>/native/myRustLib/, and the C-Interop compilation unit is registered under the name myRustLib.

Multi-Target Cross-Compilation

Compile for all four supported native targets at once:

kreate { platform { multiplatform { cInterop { enabled.set(true) rustTargets.set(listOf( "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-pc-windows-gnu" )) linux { // applied to both linuxX64 and linuxArm64 } macos { // applied to macosArm64 } mingw { // applied to mingwX64 } } } } }

All four targets are compiled in sequence and their release directories are all listed in the generated .def file's libraryPaths.

Custom Def File Location

Change where the Kotlin/Native definition file is written:

kreate { platform { multiplatform { cInterop { enabled.set(true) defFile { fileName.set("bindings.def") dirName.set("kotlin-native") } } } } }

The definition file is written to <module>/cinterop/<projectName>/kotlin-native/bindings.def.

Full Configuration

All available options combined:

kreate { platform { multiplatform { cInterop { enabled.set(true) nameOverride.set("mylib") projectDirectory.set(layout.projectDirectory.dir("rust")) packageNameOverride.set("com.davils.myapp.native") rustTargets.set(listOf( "x86_64-unknown-linux-gnu", "aarch64-apple-darwin" )) defFile { fileName.set("cinterop.def") dirName.set("defs") } linux { compilations.all { kotlinOptions.freeCompilerArgs += listOf("-opt") } } macos { } } } } }
25 April 2026