# Kotlin/Native with C++ libraries?

**URL:** <https://discuss.kotlinlang.org/t/kotlin-native-with-c-libraries/2490>\
**Category:** Language Design\
**Created:** [April 10, 2017, 11:06am UTC](https://discuss.kotlinlang.org/t/kotlin-native-with-c-libraries/2490 "2017-04-10T11:06:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguelangellv](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/miguelangellv/32/2432_2.png) [@miguelangellv](https://discuss.kotlinlang.org/u/miguelangellv)\
**Post date:** [April 10, 2017, 11:06am UTC](https://discuss.kotlinlang.org/t/kotlin-native-with-c-libraries/2490/1 "2017-04-10T11:06:14Z")

</div>

Will Kotlin Native support call to C++ libraries or only C?

---

<div class="post-metadata">

**Author:** ![edgeone](https://avatars.discourse-cdn.com/v4/letter/e/ee59a6/32.png) [@edgeone](https://discuss.kotlinlang.org/u/edgeone)\
**Post date:** [April 11, 2017, 9:07am UTC](https://discuss.kotlinlang.org/t/kotlin-native-with-c-libraries/2490/2 "2017-04-11T09:07:58Z")

</div>

hello, C++ ain’t have standard ABI, there is itanium ABI and M$ ABI

---

<div class="post-metadata">

**Author:** ![Nikolay.Igotti](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/nikolay.igotti/32/2344_2.png) [@Nikolay.Igotti](https://discuss.kotlinlang.org/u/Nikolay.Igotti)\
**Post date:** [April 17, 2017, 12:24pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-with-c-libraries/2490/3 "2017-04-17T12:24:27Z")

</div>

Calls to C++ libraries are hard from point of view of creating apropriate semantical mappings, as many ~~crazy~~ advanced C++ libraries like Boost and their ~~relatively sane~~ easier to work with sibilings like STL are kind of languages on their own, so mapping them to Kotlin is pretty hard. OTOH, many libraries doing one clear thing (zlib, libpng, ffmpeg) do have C interface, so this shall be not much of a problem use them in Kotlin/Native.

---

<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:** [July 28, 2017, 12:34pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-with-c-libraries/2490/4 "2017-07-28T12:34:39Z")

</div>

On the other hand some platform APIs have only C++ interface.  
For example – gdiplus on windows.

---

<div class="post-metadata">

**Author:** ![HughG](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@HughG](https://discuss.kotlinlang.org/u/HughG)\
**Post date:** [July 30, 2017, 8:13am UTC](https://discuss.kotlinlang.org/t/kotlin-native-with-c-libraries/2490/5 "2017-07-30T08:13:30Z")

</div>

You could try going via SWIG: [SWIG and C++](http://swig.org/Doc3.0/SWIGPlus.html#) SWIGPLUS.HTML - either by extending SWIG to generate Kotlin; or you might be able to just have it generate its low-level C-to-C++ wrappers, ten is those directly from Kotlin. I’ve never actually used SWIG, though, I just know it exists.

---

<div class="post-metadata">

**Author:** ![alanfo](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@alanfo](https://discuss.kotlinlang.org/u/alanfo)\
**Post date:** [August 1, 2017, 9:14am UTC](https://discuss.kotlinlang.org/t/kotlin-native-with-c-libraries/2490/6 "2017-08-01T09:14:13Z")

</div>

After several years of trying to write Windows applications using C++/MFC, I came to the conclusion in the late 1990’s that writing GUI applications was best left to ‘easier’ languages such as VB5/6 and (later) C#. Productivity is much better and performance is usually more than adequate.

Even if Kotlin Native did support C++ libraries, you’d probably end up writing C++ code with Kotlin syntax which, I suspect, would be an unpleasant experience. So, if GUI programming is your thing and coverage for your platform is already provided, I’d just stick with the JVM version of Kotlin for writing such applications.
