# Native

**URL:** https://discuss.kotlinlang.org/c/native/15.md

[Latest](https://discuss.kotlinlang.org/latest.md) · [Categories](https://discuss.kotlinlang.org/categories.md)

---

## [About the Native category](https://discuss.kotlinlang.org/t/about-the-native-category/3549)

<div class="topic-metadata">

**Author:** [@yole](https://discuss.kotlinlang.org/u/yole)\
**Replies:** 0\
**Last updated:** [June 29, 2017, 7:26am UTC](https://discuss.kotlinlang.org/t/about-the-native-category/3549 "2017-06-29T07:26:49Z")

</div>

Questions and discussion on development with Kotlin/Native. See also related channels in Kotlin Slack (you can sign up here): #kotlin-native #multiplatform

---

## [Integrating a python code with kotlin](https://discuss.kotlinlang.org/t/integrating-a-python-code-with-kotlin/24639)

<div class="topic-metadata">

**Author:** [@dagim](https://discuss.kotlinlang.org/u/dagim)\
**Replies:** 7\
**Last updated:** [September 1, 2026, 10:32pm UTC](https://discuss.kotlinlang.org/t/integrating-a-python-code-with-kotlin/24639 "2026-09-01T22:32:36Z")

</div>

Hello, I recently wrote a python program and I wanted to integrate the program with my Kotlin application and anyone could tell me how can I do that ?

---

## [Native on STM32 with very limited RAM and code space](https://discuss.kotlinlang.org/t/native-on-stm32-with-very-limited-ram-and-code-space/30968)

<div class="topic-metadata">

**Author:** [@fish](https://discuss.kotlinlang.org/u/fish)\
**Replies:** 0\
**Last updated:** [February 19, 2026, 9:53am UTC](https://discuss.kotlinlang.org/t/native-on-stm32-with-very-limited-ram-and-code-space/30968 "2026-02-19T09:53:44Z")

</div>

I’m somewhat interested in trying to get KN running on Pebble hardware (stm32 CPU, 128k max code + heap size at most for only one model, 64k has better support). Is this even feasible? These are the arguments C files ge…

---

## [Segfault crash invoking kotlinc-native (konan)](https://discuss.kotlinlang.org/t/segfault-crash-invoking-kotlinc-native-konan/30852)

<div class="topic-metadata">

**Author:** [@abdillah](https://discuss.kotlinlang.org/u/abdillah)\
**Replies:** 0\
**Last updated:** [November 10, 2025, 11:19pm UTC](https://discuss.kotlinlang.org/t/segfault-crash-invoking-kotlinc-native-konan/30852 "2025-11-10T23:19:40Z")

</div>

Hello, I would like to use Kotlin as native language. So, I create a simple file and invoke a compiler: $ kotlinc-native -version Current kotlin-native dir: /nix/store/\<hash\>-kotlin-native-2.2.21 New writeable ko…

---

## [Mismatch between glibc versions (Kotlin/Native on Linux)](https://discuss.kotlinlang.org/t/mismatch-between-glibc-versions-kotlin-native-on-linux/30780)

<div class="topic-metadata">

**Author:** [@marandil](https://discuss.kotlinlang.org/u/marandil)\
**Replies:** 0\
**Last updated:** [October 2, 2025, 4:02pm UTC](https://discuss.kotlinlang.org/t/mismatch-between-glibc-versions-kotlin-native-on-linux/30780 "2025-10-02T16:02:30Z")

</div>

Consider the following example: Project foo is a KMP library with cinterop dependencies. The dependencies are built with system toolchain and target system libraries, e.g. glibc \> 2.20 Project bar is a KMP / KN executa…

---

## [Provide a way to avoid GC safepoint](https://discuss.kotlinlang.org/t/provide-a-way-to-avoid-gc-safepoint/30505)

<div class="topic-metadata">

**Author:** [@cpdyj](https://discuss.kotlinlang.org/u/cpdyj)\
**Replies:** 3\
**Last updated:** [July 5, 2025, 6:12pm UTC](https://discuss.kotlinlang.org/t/provide-a-way-to-avoid-gc-safepoint/30505 "2025-07-05T18:12:47Z")

</div>

I want to writing a library just like java.lang.ProcessBuilder But I found it’s difficult to complete the project in pure Kotlin. When I executing the following code, it’s hang… val pid = fork() if(pid == 0) GC.collec…

---

## [Can I make this algorithm faster?](https://discuss.kotlinlang.org/t/can-i-make-this-algorithm-faster/30425)

<div class="topic-metadata">

**Author:** [@ex-exist](https://discuss.kotlinlang.org/u/ex-exist)\
**Replies:** 17\
**Last updated:** [June 25, 2025, 3:21pm UTC](https://discuss.kotlinlang.org/t/can-i-make-this-algorithm-faster/30425 "2025-06-25T15:21:37Z")

</div>

I have this code: fun main() { measureTimeMillis { LongStream.rangeClosed(1, 1\_000\_000) .parallel() .mapToObj(BigInteger::valueOf) .reduce(BigInteger::parallelMultiply) …

---

## [Reverse C interop passing array to Kotlin Native and back](https://discuss.kotlinlang.org/t/reverse-c-interop-passing-array-to-kotlin-native-and-back/20592)

<div class="topic-metadata">

**Author:** [@u10q50](https://discuss.kotlinlang.org/u/u10q50)\
**Replies:** 1\
**Last updated:** [June 13, 2025, 6:46pm UTC](https://discuss.kotlinlang.org/t/reverse-c-interop-passing-array-to-kotlin-native-and-back/20592 "2025-06-13T18:46:10Z")

</div>

Hello, I got stuck while trying to write a library where kotlin code is called from another C library which is loaded in another application with a strict interface so I was following these tutorials to see how the inte…

---

## [Change .konan folder location](https://discuss.kotlinlang.org/t/change-konan-folder-location/18309)

<div class="topic-metadata">

**Author:** [@lamba92](https://discuss.kotlinlang.org/u/lamba92)\
**Replies:** 3\
**Last updated:** [April 26, 2025, 7:25pm UTC](https://discuss.kotlinlang.org/t/change-konan-folder-location/18309 "2025-04-26T19:25:08Z")

</div>

When building K/N using Gradle the default path for the caches is ~/.konan. Is it possible to change that path? For example similarly to how Gradle cache fodler can be set using the env variable GRADLE\_USER\_HOME.

---

## [How to create Kotlin Lambda form C](https://discuss.kotlinlang.org/t/how-to-create-kotlin-lambda-form-c/30141)

<div class="topic-metadata">

**Author:** [@Messiahfy](https://discuss.kotlinlang.org/u/Messiahfy)\
**Replies:** 1\
**Last updated:** [March 25, 2025, 9:43am UTC](https://discuss.kotlinlang.org/t/how-to-create-kotlin-lambda-form-c/30141 "2025-03-25T09:43:04Z")

</div>

I’m trying to call kotlin(Native) function in C code, this is my kotlin function ： object LambdaTest { var configA = 0 var configB = "" fun config(block: LambdaTest.() -\> Unit) { this.block() } …

---

## [Understanding Kotlin's coroutines performance](https://discuss.kotlinlang.org/t/understanding-kotlins-coroutines-performance/12207)

<div class="topic-metadata">

**Author:** [@Viperwow](https://discuss.kotlinlang.org/u/Viperwow)\
**Replies:** 5\
**Last updated:** [March 4, 2025, 4:11pm UTC](https://discuss.kotlinlang.org/t/understanding-kotlins-coroutines-performance/12207 "2025-03-04T16:11:06Z")

</div>

Hi, everybody, I’m kind of new in a Kotlin, but I’ve got a few questions already. Fortunately, about a single topic) Somewhere in the Kotlin’s documentation, developers have mentioned the fact, that coroutines are light…

---

## [How to use Kotlin native to compile a kotlin file which imports third party package](https://discuss.kotlinlang.org/t/how-to-use-kotlin-native-to-compile-a-kotlin-file-which-imports-third-party-package/29784)

<div class="topic-metadata">

**Author:** [@Song\_Zhang.jrfj](https://discuss.kotlinlang.org/u/Song_Zhang.jrfj)\
**Replies:** 1\
**Last updated:** [January 23, 2025, 9:02am UTC](https://discuss.kotlinlang.org/t/how-to-use-kotlin-native-to-compile-a-kotlin-file-which-imports-third-party-package/29784 "2025-01-23T09:02:17Z")

</div>

I have a Kotlin file import kotlinx.datetime.Clock fun currentTime(): Long { return Clock.System.now().toEpochMilliseconds() } However, kotlinx.datetime.Clock is from third party library. How can I pass the library…

---

## [Different behavior between native and K/N](https://discuss.kotlinlang.org/t/different-behavior-between-native-and-k-n/29666)

<div class="topic-metadata">

**Author:** [@kirill.obukhov](https://discuss.kotlinlang.org/u/kirill.obukhov)\
**Replies:** 1\
**Last updated:** [January 6, 2025, 6:07pm UTC](https://discuss.kotlinlang.org/t/different-behavior-between-native-and-k-n/29666 "2025-01-06T18:07:45Z")

</div>

I wrote the code that uses the openssl library to generate a key pair and then import the public key into a file. I couldn’t figure out the problem and wrote equivalent code in C. To my surprise, the native code worked a…

---

## [Gradle Kotlin Build: JVM Compatibility Issue with Java 23 and Kotlin 2.0.20](https://discuss.kotlinlang.org/t/gradle-kotlin-build-jvm-compatibility-issue-with-java-23-and-kotlin-2-0-20/29556)

<div class="topic-metadata">

**Author:** [@europa](https://discuss.kotlinlang.org/u/europa)\
**Replies:** 2\
**Last updated:** [December 29, 2024, 10:21am UTC](https://discuss.kotlinlang.org/t/gradle-kotlin-build-jvm-compatibility-issue-with-java-23-and-kotlin-2-0-20/29556 "2024-12-29T10:21:01Z")

</div>

Hi Everyone, I’m facing a compatibility issue in my project involving Gradle, Kotlin, and Java 23. Here’s the problem: Problem Description Error: Execution failed for task ':compileKotlin'. \> Inconsistent JVM-target c…

---

## [How to call stat() C function to get file type?](https://discuss.kotlinlang.org/t/how-to-call-stat-c-function-to-get-file-type/29541)

<div class="topic-metadata">

**Author:** [@kornerr](https://discuss.kotlinlang.org/u/kornerr)\
**Replies:** 0\
**Last updated:** [November 18, 2024, 8:39pm UTC](https://discuss.kotlinlang.org/t/how-to-call-stat-c-function-to-get-file-type/29541 "2024-11-18T20:39:26Z")

</div>

Hi, I’m trying to call stat() C function (from sys/stat.h) to get actual file/dir type that are behind symbolic links. Here’s what I have at the moment: val dir = opendir(path) if (dir != null) { try {…

---

## [Is there a \_\_ FILE\_\_, \_\_ LINE\_\_, \_\_FUNCTION\_\_ macro similar to C in kotlin native?](https://discuss.kotlinlang.org/t/is-there-a-file-line-function-macro-similar-to-c-in-kotlin-native/24205)

<div class="topic-metadata">

**Author:** [@xunanmu](https://discuss.kotlinlang.org/u/xunanmu)\
**Replies:** 4\
**Last updated:** [November 1, 2024, 8:58pm UTC](https://discuss.kotlinlang.org/t/is-there-a-file-line-function-macro-similar-to-c-in-kotlin-native/24205 "2024-11-01T20:58:12Z")

</div>

Are there \_ \_ FILE\_\_, \_ \_ LINE\_\_, \_ \_ Function\_\_ macros similar to C in Kotlin native language? I need them to logger on the Linux system.

---

## [How can I ensure my Kotlin/Native DLL is compatible with UWP sandboxing](https://discuss.kotlinlang.org/t/how-can-i-ensure-my-kotlin-native-dll-is-compatible-with-uwp-sandboxing/29242)

<div class="topic-metadata">

**Author:** [@dollarfinancials](https://discuss.kotlinlang.org/u/dollarfinancials)\
**Replies:** 0\
**Last updated:** [September 16, 2024, 5:10pm UTC](https://discuss.kotlinlang.org/t/how-can-i-ensure-my-kotlin-native-dll-is-compatible-with-uwp-sandboxing/29242 "2024-09-16T17:10:46Z")

</div>

To ensure your Kotlin/Native DLL is compatible with UWP sandboxing when using it in a C# UWP application, follow these steps: 1. Package the DLL as Content In your C# UWP project, add the Kotlin/Native DLL as a “Content…

---

## [How to reference Kotlin/Native DLLs from C# code in a Windows/UWP app?](https://discuss.kotlinlang.org/t/how-to-reference-kotlin-native-dlls-from-c-code-in-a-windows-uwp-app/25208)

<div class="topic-metadata">

**Author:** [@shudv](https://discuss.kotlinlang.org/u/shudv)\
**Replies:** 1\
**Last updated:** [September 12, 2024, 1:59am UTC](https://discuss.kotlinlang.org/t/how-to-reference-kotlin-native-dlls-from-c-code-in-a-windows-uwp-app/25208 "2024-09-12T01:59:47Z")

</div>

I was able to successfully generate a windows DLL by following instructions here. Although, I haven’t been able to consume the DLL in my C# Windows app and haven’t found any tutorial/blog on how to do so. I have tried fo…

---

## [How do I convert an array pointer returned by a native library into a class in C#](https://discuss.kotlinlang.org/t/how-do-i-convert-an-array-pointer-returned-by-a-native-library-into-a-class-in-c/28979)

<div class="topic-metadata">

**Author:** [@BKT](https://discuss.kotlinlang.org/u/BKT)\
**Replies:** 0\
**Last updated:** [July 29, 2024, 11:43pm UTC](https://discuss.kotlinlang.org/t/how-do-i-convert-an-array-pointer-returned-by-a-native-library-into-a-class-in-c/28979 "2024-07-29T23:43:17Z")

</div>

Given this delegate: public delegate\* unmanaged\[Cdecl\]\<lib\_kref\_Resource, lib\_kref\_kotlin\_Array\> listUsers; With the next struct definition (generated with ClangSharpPInvokeGenerator): typedef struct { lib\_KNativePt…

---

## [Error: self-signed certificate in certificate chain](https://discuss.kotlinlang.org/t/error-self-signed-certificate-in-certificate-chain/28874)

<div class="topic-metadata">

**Author:** [@wucong1997](https://discuss.kotlinlang.org/u/wucong1997)\
**Replies:** 1\
**Last updated:** [July 12, 2024, 11:58am UTC](https://discuss.kotlinlang.org/t/error-self-signed-certificate-in-certificate-chain/28874 "2024-07-12T11:58:06Z")

</div>

Hi, When compiling Kotlin native on Linux, run. /gradlew publish, the following error occurs: “self-signed certificate in certificate chain”. How to deal with this kind of problem?

---

## [Swift enum CLAuthorizationStatus value](https://discuss.kotlinlang.org/t/swift-enum-clauthorizationstatus-value/14318)

<div class="topic-metadata">

**Author:** [@guillodacosta](https://discuss.kotlinlang.org/u/guillodacosta)\
**Replies:** 1\
**Last updated:** [June 18, 2024, 9:15am UTC](https://discuss.kotlinlang.org/t/swift-enum-clauthorizationstatus-value/14318 "2024-06-18T09:15:31Z")

</div>

Hi, I trying to ask for a location permissions and I did applied a when condition with CLLocationManager.authorizationStatus() trying to compare with your possible enum CLAuthorizationStatus values. But I cannot use th…

---

## [Get a reference to a CValue](https://discuss.kotlinlang.org/t/get-a-reference-to-a-cvalue/28630)

<div class="topic-metadata">

**Author:** [@ObserverOfTime](https://discuss.kotlinlang.org/u/ObserverOfTime)\
**Replies:** 0\
**Last updated:** [May 18, 2024, 11:29am UTC](https://discuss.kotlinlang.org/t/get-a-reference-to-a-cvalue/28630 "2024-05-18T11:29:25Z")

</div>

Hello, I’m trying to implement Kotlin/Native bindings for tree-sitter and I have a Node class that looks kinda like this: class Node(internal val self: CValue\<TSNode\>) { val symbol: UShort get() = ts\_node\_s…

---

## [Unresolved reference](https://discuss.kotlinlang.org/t/unresolved-reference/28587)

<div class="topic-metadata">

**Author:** [@alx](https://discuss.kotlinlang.org/u/alx)\
**Replies:** 1\
**Last updated:** [May 8, 2024, 1:47pm UTC](https://discuss.kotlinlang.org/t/unresolved-reference/28587 "2024-05-08T13:47:09Z")

</div>

I would like to fix ‘Unresolved reference: roll’ on line 73 in my code. I read the online reference for my function here but this didn’t help me. I tried coding ‘android.R.string.roll’, removing the ‘.roll’ and importing…

---

## [Data classes optimization](https://discuss.kotlinlang.org/t/data-classes-optimization/28421)

<div class="topic-metadata">

**Author:** [@Alexander\_Nutz](https://discuss.kotlinlang.org/u/Alexander_Nutz)\
**Replies:** 6\
**Last updated:** [April 27, 2024, 9:33pm UTC](https://discuss.kotlinlang.org/t/data-classes-optimization/28421 "2024-04-27T21:33:04Z")

</div>

It is possible to treat data classes with only immutable members as structs. Doing this would increase performance a lot since you don’t need to heap allocate every simple read-only data class. Also LLVM could optimize…

---

## [Kotlin/Native without build automation tool](https://discuss.kotlinlang.org/t/kotlin-native-without-build-automation-tool/28221)

<div class="topic-metadata">

**Author:** [@RPD-09](https://discuss.kotlinlang.org/u/RPD-09)\
**Replies:** 2\
**Last updated:** [March 8, 2024, 6:56am UTC](https://discuss.kotlinlang.org/t/kotlin-native-without-build-automation-tool/28221 "2024-03-08T06:56:44Z")

</div>

Hello. I’m a newbie in Kotlin programming. I have a question. Can I use Kotlin/Native to create app without build automation tools like Gradle, Maven, Ant, and other similar tools?

---

## [Base and child Kotlin libraries](https://discuss.kotlinlang.org/t/base-and-child-kotlin-libraries/28229)

<div class="topic-metadata">

**Author:** [@keaukraine](https://discuss.kotlinlang.org/u/keaukraine)\
**Replies:** 0\
**Last updated:** [February 26, 2024, 9:31pm UTC](https://discuss.kotlinlang.org/t/base-and-child-kotlin-libraries/28229 "2024-02-26T21:31:43Z")

</div>

Hello. I need to have a following structure: A base Kotlin native library which will have some abstract class Pet. It will target JS, Android, iOS and MacOS. Native apps will do something with these pets. Then I shoul…

---

## [Which methods are used for optimisation?](https://discuss.kotlinlang.org/t/which-methods-are-used-for-optimisation/28189)

<div class="topic-metadata">

**Author:** [@coditive](https://discuss.kotlinlang.org/u/coditive)\
**Replies:** 10\
**Last updated:** [February 24, 2024, 8:01am UTC](https://discuss.kotlinlang.org/t/which-methods-are-used-for-optimisation/28189 "2024-02-24T08:01:48Z")

</div>

Hi All, i want to know which type of map initialisation is mostly preferred when optimizing your code: map\[key\] = map.getOrPut(key){ defaultValue} + someOperation map\[key\] = map\[key\]?.let{ it → someOperation} ?: defaul…

---

## [Kotlin/JVM Interoperability with native code w/o JNI](https://discuss.kotlinlang.org/t/kotlin-jvm-interoperability-with-native-code-w-o-jni/27810)

<div class="topic-metadata">

**Author:** [@egeb\_15](https://discuss.kotlinlang.org/u/egeb_15)\
**Replies:** 1\
**Last updated:** [February 23, 2024, 9:37am UTC](https://discuss.kotlinlang.org/t/kotlin-jvm-interoperability-with-native-code-w-o-jni/27810 "2024-02-23T09:37:51Z")

</div>

Hello everyone, I’ve been trying to use integrate our C++ business code to interoperate with iOS and Android in a KMM project. I know that one normally uses JNI to interact with C++ code from the Android side, but since …

---

## [Statically allocating \`CVariable\`s](https://discuss.kotlinlang.org/t/statically-allocating-cvariable-s/28184)

<div class="topic-metadata">

**Author:** [@Alexander\_Nutz](https://discuss.kotlinlang.org/u/Alexander_Nutz)\
**Replies:** 1\
**Last updated:** [February 23, 2024, 8:40am UTC](https://discuss.kotlinlang.org/t/statically-allocating-cvariable-s/28184 "2024-02-23T08:40:25Z")

</div>

When a C function needs a struct as parameter, you have to allocate it on the heap, but in most cases, we could just store the struct in the output binary. Proposing: static allocation functions. Functions that are res…

---

## [Simple SIMD Vector Operations](https://discuss.kotlinlang.org/t/simple-simd-vector-operations/28185)

<div class="topic-metadata">

**Author:** [@Alexander\_Nutz](https://discuss.kotlinlang.org/u/Alexander_Nutz)\
**Replies:** 2\
**Last updated:** [February 23, 2024, 8:36am UTC](https://discuss.kotlinlang.org/t/simple-simd-vector-operations/28185 "2024-02-23T08:36:03Z")

</div>

As you (might) know, there is Vector128 in K/N. Vector128 is a SIMD (= Single Instruction Multiple Data) (stored in SSE 2 XMM registers on x86) value type. This type can contain 16 chars, 8 shorts, 4 ints, 4 floats, 2 d…

[Next page](https://discuss.kotlinlang.org/c/native/15.md?page=1)
