I have the following code on Windows x64 (Kotlin 1...
# kotlin-native
p
I have the following code on Windows x64 (Kotlin 1.3.72):
Copy code
package sample

import io.ktor.client.HttpClient
import io.ktor.client.engine.curl.Curl
import io.ktor.client.features.json.JsonFeature
import io.ktor.client.features.json.serializer.KotlinxSerializer
import io.ktor.client.request.get
import kotlinx.coroutines.runBlocking

fun main() = runBlocking<Unit> {
    val client = HttpClient(Curl) {
        install(JsonFeature) {
            serializer = KotlinxSerializer()
        }
    }

    val response = client.get<String>("<http://google.de>")

    println(response)
}
However the linker fails with this error message:
C:\Users\Patrick\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1\bin\ld: cannot find -lcurl
- This tells me that curl seems to be missing. However it should be installed on Windows 10 by default. I also downloaded the curl binaries and added them to the include path, but still nothing. Any ideas why the linker fails here?
This is the build.gradle.kts:
Copy code
plugins {
    kotlin("multiplatform") version ("1.3.72")
}

repositories {
    mavenCentral()
    jcenter()
}

kotlin {

    val ktorVersion = "1.3.2"

    // For ARM, should be changed to iosArm32 or iosArm64
    // For Linux, should be changed to e.g. linuxX64
    // For MacOS, should be changed to e.g. macosX64
    // For Windows, should be changed to e.g. mingwX64
    mingwX64("mingw") {
        binaries {
            executable {
                entryPoint("sample.main")
            }
        }
    }

    sourceSets {
        commonMain {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("io.ktor:ktor-client-curl:$ktorVersion")
                implementation("io.ktor:ktor-client-serialization-native:$ktorVersion")
                implementation("io.ktor:ktor-client-json-native:$ktorVersion")
            }
        }
        commonTest {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        mingwX64().compilations["main"].defaultSourceSet {
            dependencies {
            }
        }
        mingwX64().compilations["test"].defaultSourceSet {
        }
    }
}
a
Similar issue from the forum(https://discuss.kotlinlang.org/t/issue-with-ktor-on-windows/16042), unfortunately with no answer from the topic starter.
p
Thanks, that works 🎉
🆒 2