Clear steps for importing a native C library in Kotlin using CLion

438 Views Asked by At

I am trying out Kotlin Native and it seems to work.

But the page giving instruction on adding a C library is not clear enough.

For example lets say I wanted to import libcurl and libxml for making a webscraper.

Or say wanted to make GUIs by using Qt.

How would I import this library in Clion.

Please give clear steps.

I want to turn this question as a easy wiki like guide for myself and others new to native.

Why do I need to install the library SO in Linux as mentioned in the Kotlin Native guide? Isn't adding source code enough.

Edit: https://github.com/JetBrains/kotlin-native/blob/master/LIBRARIES.md

First lets create a library:

$ cinterop -h /usr/include/math.h -pkg libc.math -o math

Q: Can't I just use gradle for dependency management?

Q: Why pass libc.math? What should I pass for other libraries like libcurl?

Q: What is -pkg?

I'm assuming -o math is the klib name.

0

There are 0 best solutions below