kotlin-hands-on / hands-on

Apache License 2.0
130 stars 176 forks source link

Unresolved reference: main #135

Open shalva97 opened 3 years ago

shalva97 commented 3 years ago

hello, decided to do some kotlin native and found this hands-on/Introduction to Kotlin Native/04_AddingInteropToBuild.md

there it says to add some newlines to generate some header files. but I get errors:

e: /home/shalva/intellijProjects/IdeaProjects/untitled/build.gradle.kts:26:22: Unresolved reference: main
e: /home/shalva/intellijProjects/IdeaProjects/untitled/build.gradle.kts:27:13: Unresolved reference: cinterops
e: /home/shalva/intellijProjects/IdeaProjects/untitled/build.gradle.kts:28:17: Unresolved reference: libcurl

Build file '/home/shalva/intellijProjects/IdeaProjects/untitled/build.gradle.kts' line: 26

Script compilation errors:

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

my build file is auto generated from intellij:

plugins {
    kotlin("multiplatform") version "1.5.0-RC"
}

group = "me.shalva.firsplugin"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

kotlin {
    val hostOs = System.getProperty("os.name")
    val isMingwX64 = hostOs.startsWith("Windows")
    val nativeTarget = when {
        hostOs == "Mac OS X" -> macosX64("native")
        hostOs == "Linux" -> linuxX64("native")
        isMingwX64 -> mingwX64("native")
        else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
    }

    nativeTarget.apply {

        compilations.main { // NL
            cinterops {     // NL
                libcurl     // NL
            }               // NL
        }

        binaries {
            executable {
                entryPoint = "main"
            }
        }
    }
    sourceSets {
        val nativeMain by getting
        val nativeTest by getting
    }
}