My first Gradle native app


I build my first KN as below, gradle init, then updating the build.gradle with the code below, then running gradle build, using my Mac:


buildscript {
    repositories {
        maven {
            url ""
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"

apply plugin: 'konan'

// Compile this component for 64-bit MacOS, Linux and Windows.
 konan.targets = [
                'android_arm32', 'android_arm64',
               //  'mingw_x64',
                //  'linux_x64', 'linux_arm32_hfp',
               //  'ios_x64', 'ios_arm32', 'ios_arm64'

konanArtifacts {
    library('utils') {
        srcFiles fileTree('src/libs/utils')
    program('hello') {
        libraries {
            artifact 'utils'

My app structure is:


hello.kt (app):

fun main() {
    println("Hello Gradle!")

foo.kt (lib):

fun foo(){
    println("Hello Gradle! again")

by running gradle build: I got the libs and executables as in the below tree:


I’ve the below questions:

  1. Nothing had been generated for the following targets, this is why I made them as comments:
    iOS: ios_x64, ios_arm32, ios_arm64
    Raspberry: linux_arm32_hfp
    Windows: mingw_x64
    Linux: linux_x64

  2. Are all the generated libraries utils.Klib are same, so I can pick anyone of them and use it anywhere, or I’ve to pick as per the required target.

  3. How to call the function foo that is part of the library in the main function, I tried import utils then calling but did not work.