Definition file

Edit pageLast modified: 13 February 2025

Kotlin/Native enables you to consume C and Objective-C libraries, allowing you to use their functionality in Kotlin. A special tool called cinterop takes a C or an Objective-C library and generates the corresponding Kotlin bindings, so that the library's methods can be used in your Kotlin code as usual.

To generate these bindings, each library needs a definition file, usually with the same name as the library. This is a property file that describes exactly how the library should be consumed. See the full list of available properties.

Here's a general workflow when working with a project:

  1. Create a .def file describing what to include in the bindings.

  2. Use the generated bindings in your Kotlin code.

  3. Run the Kotlin/Native compiler to produce the final executable.