When developing with Kotlin-Native, many libraries are missing in the current version, so we need to supplement with C/C++. This article uses Linux as an example to demonstrate how to use C/C++ in Kotlin-Native.
- IntelliJ IDEA Community
- JDK 17
- CMake
- Linux
Interoperability with C
Create an app using C Interop and libcurl – tutorial
selcarpa/c_link_demo
└── c_link_demo
├── c_link_demo_c
│ ├── CMakeLists.txt
│ ├── library.c
│ └── library.h
└── c_link_demo_kt
├── build.gradle.kts
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
└── src
├── commonMain
│ ├── kotlin
│ │ └── Main.kt
│ └── resources
└── nativeInterop
└── cinterop
└── c_lib_demo.def
This example uses a C library.