Kotlin-native: Cannot compile to linux target on macOS

Created on 25 Dec 2017  Â·  5Comments  Â·  Source: JetBrains/kotlin-native

My kotlin-native compiler was up-to-date and cannot compile to linux target on macOS:

$ kotlinc main.kt -target linux -o main
exception: java.lang.IllegalStateException: Target LINUX is not available on the MACBOOK host
    at org.jetbrains.kotlin.backend.konan.KonanConfig.<init>(KonanConfig.kt:49)
    at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:58)
    at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:39)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:108)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:52)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:70)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:36)
    at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:157)
    at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:148)
    at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:183)
    at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:174)
    at org.jetbrains.kotlin.backend.konan.util.UtilKt.profileIf(util.kt:34)
    at org.jetbrains.kotlin.backend.konan.util.UtilKt.profile(util.kt:29)
    at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:176)
    at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:188)
    at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:115)

And here is my build.gradle file:

buildscript {
    ext.kotlin_version = '1.2.10'

    repositories {
        mavenCentral()
        maven {
            url  "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
        }
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"
    }
}

apply plugin: 'konan'
apply plugin: 'idea'

konan.targets = ['macbook', 'linux']

konanArtifacts {
    program('scavenger')
}

The gradle build output has the following warrning:

The target is not enabled on the current host: linux

Most helpful comment

Golang can be cross-platform compiler, such as I can compile Linux binary or Android binary on my macOS. Does Kotlin support cross-platform compilation in the future? I think Kotlin's Native future must be very strong! Kotlin is very advantageous!

All 5 comments

Isn't it clear that you can't compile to Linux on a macOS host? 🤔

On Dec 25, 2017 3:58 PM, "Taio Jia" notifications@github.com wrote:

My kotlin-native compiler was up-to-date and cannot compile to linux
target on macOS:

$ kotlinc main.kt -target linux -o main
exception: java.lang.IllegalStateException: Target LINUX is not available on the MACBOOK host
at org.jetbrains.kotlin.backend.konan.KonanConfig.(KonanConfig.kt:49)
at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:58)
at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:39)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:108)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:52)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:70)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:36)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:157)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:148)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:183)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:174)
at org.jetbrains.kotlin.backend.konan.util.UtilKt.profileIf(util.kt:34)
at org.jetbrains.kotlin.backend.konan.util.UtilKt.profile(util.kt:29)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:176)
at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:188)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:115)

And here is my build.gradle file:

buildscript {
ext.kotlin_version = '1.2.10'

repositories {
    mavenCentral()
    maven {
        url  "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
    }
}
dependencies {
    classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"
}

}

apply plugin: 'konan'
apply plugin: 'idea'

konan.targets = ['macbook', 'linux']

konanArtifacts {
program('scavenger')
}

The gradle build output has the following warrning:

The target is not enabled on the current host: linux

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/JetBrains/kotlin-native/issues/1191, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AJwYe2k-Xnusdkc8oqU8IT3BV9m35ovrks5tD7gdgaJpZM4RMUmM
.

@StefMa I wanna build my project to a linux binary on my macOS system and how to? ths!

Not all cross-compilation host/target pairs are supported, see https://github.com/JetBrains/kotlin-native/blob/master/RELEASE_NOTES.md for details.

If you haven't access to a Linux machine you can create a Docker image,
mount your project and let the image build your app...

On Dec 25, 2017 5:22 PM, "Nikolay Igotti" notifications@github.com wrote:

Closed #1191 https://github.com/JetBrains/kotlin-native/issues/1191.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JetBrains/kotlin-native/issues/1191#event-1401112567,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJwYe0mQ-x2IhkY_0pGM6Vcg7gjB8y3Sks5tD8u0gaJpZM4RMUmM
.

Golang can be cross-platform compiler, such as I can compile Linux binary or Android binary on my macOS. Does Kotlin support cross-platform compilation in the future? I think Kotlin's Native future must be very strong! Kotlin is very advantageous!

Was this page helpful?
0 / 5 - 0 ratings