# Kotlin Native load dll

**URL:** <https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152>\
**Category:** Native\
**Created:** [January 14, 2019, 1:47pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152 "2019-01-14T13:47:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![solomkaromanolegovech](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@solomkaromanolegovech](https://discuss.kotlinlang.org/u/solomkaromanolegovech)\
**Post date:** [January 14, 2019, 1:47pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/1 "2019-01-14T13:47:31Z")

</div>

Will it be possible to connect dll to kotlin as easy as “ctypes” in python? For example: cinterop.load (“name.dll”)

---

<div class="post-metadata">

**Author:** ![lamba92](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lamba92/32/5089_2.png) [@lamba92](https://discuss.kotlinlang.org/u/lamba92)\
**Post date:** [January 14, 2019, 2:26pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/2 "2019-01-14T14:26:11Z")

</div>

Nope, Kotlin is a statically typed language, you have to define the methods available in the dll. cinterops does just that for you automatically.

---

<div class="post-metadata">

**Author:** ![solomkaromanolegovech](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@solomkaromanolegovech](https://discuss.kotlinlang.org/u/solomkaromanolegovech)\
**Post date:** [January 14, 2019, 3:21pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/3 "2019-01-14T15:21:42Z")

</div>

can i use dll from delphi if i write them a “.h” file?

---

<div class="post-metadata">

**Author:** ![msink](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/msink/32/3336_2.png) [@msink](https://discuss.kotlinlang.org/u/msink)\
**Post date:** [January 14, 2019, 9:58pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/4 "2019-01-14T21:58:29Z")

</div>

It should, but you need to create import library, using dlltool from msys2-mingw64 distribution

[http://www.mingw.org/wiki/createimportlibraries](http://www.mingw.org/wiki/createimportlibraries)

---

<div class="post-metadata">

**Author:** ![solomkaromanolegovech](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@solomkaromanolegovech](https://discuss.kotlinlang.org/u/solomkaromanolegovech)\
**Post date:** [January 15, 2019, 2:12am UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/5 "2019-01-15T02:12:56Z")

</div>

And what exactly gives “.lib”, is it possible to use someone else’s dll without the delivery “.h” in the kit?

---

<div class="post-metadata">

**Author:** ![lamba92](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lamba92/32/5089_2.png) [@lamba92](https://discuss.kotlinlang.org/u/lamba92)\
**Post date:** [January 15, 2019, 2:15am UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/6 "2019-01-15T02:15:06Z")

</div>

Have a look [here](https://kotlinlang.org/docs/reference/native/c_interop.html).

---

<div class="post-metadata">

**Author:** ![msink](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/msink/32/3336_2.png) [@msink](https://discuss.kotlinlang.org/u/msink)\
**Post date:** [January 15, 2019, 2:17am UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/7 "2019-01-15T02:17:00Z")

</div>

It should be “.dll.a”. Even more precisely - “lib\*.dll.a”

---

<div class="post-metadata">

**Author:** ![lamba92](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lamba92/32/5089_2.png) [@lamba92](https://discuss.kotlinlang.org/u/lamba92)\
**Post date:** [January 15, 2019, 1:08pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/8 "2019-01-15T13:08:10Z")

</div>

You need to have the `.h` and create the `.def`. Then using cinterop you need to tell the compiler to link your dll in the app or library you are building. In the repository of Kotlin Native there are many examples. Most of them are not commented since K/N is still in beta.

---

<div class="post-metadata">

**Author:** ![solomkaromanolegovech](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@solomkaromanolegovech](https://discuss.kotlinlang.org/u/solomkaromanolegovech)\
**Post date:** [January 15, 2019, 2:14pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-load-dll/11152/9 "2019-01-15T14:14:50Z")

</div>

In your opinion, how much time is needed for K / N to equal the readiness of kotlin to jvm.  
How do I understand the development began in 2017, then this is at least 2-3 years?
