I'm trying to upgrade one of my projects (kt-searc...
# kotlin-native
j
I'm trying to upgrade one of my projects (kt-search) to cover more multiplatform targets using kotlin 1.9.20-RC and the new improvements for making that easier in gradle. I've nearly got it working but I'm having issues with lib curl and the linux targets. On my mac m1 everything builds fine. JVM, browser, nodejs, mingwX64, macosX64, macosArm64. But with the linux targets I get two different libcurl related errors: With linuxX86:
Copy code
> Task :search-client:linkDebugTestLinuxX64 FAILED
e: /Users/jillesvangurp/.konan/dependencies/apple-llvm-20200714-macos-aarch64-essentials/bin/ld.lld invocation reported errors

The /Users/jillesvangurp/.konan/dependencies/apple-llvm-20200714-macos-aarch64-essentials/bin/ld.lld command returned non-zero exit code: 1.
output:
ld.lld: error: unable to find library -lcurl
With linuxArm64:
Copy code
> Task :search-client:transformCommonMainDependenciesMetadata FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':search-client:transformCommonMainDependenciesMetadata'.
> Could not resolve all files for configuration ':search-client:linuxArm64CompilationDependenciesMetadata'.
   > Could not resolve io.ktor:ktor-client-curl:{require 2.3.5; reject _}.
     Required by:
         project :search-client
      > No matching variant of io.ktor:ktor-client-curl:2.3.5 was found. The consumer was configured to find a library for use during 'kotlin-metadata', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'linux_arm64' but:
I need lib-curl for the Curl engine in ktor-client. Works fine with the mac native build and my tests pass with it. Is there something I need to do for this or will this only work on linux? If so, how do I prevent it from trying to run this on my mac? I would appreciate some help with that. Instead of pasting build files here, easier to just point at the Github project: https://github.com/jillesvangurp/kt-search/tree/more-multi-platform-targets The search-client module is the one that has the ktor dependency. So
gradle :search-client:build
reproduces the issue.
r
Check the docs for the Ktor curl engine. You need to have libcurl installed for it to work. And it looks like it's not available for LinuxArm64. You can probably get more help in #ktor.
j
I checked the docs. I get that it needs curl for each of the platforms it needs to build. But how do I fix not having a linux library on a mac? Also, the windows target runs fine. It's just the linux builds that don't. How is this normally done with multiplatform? Should I surround the linux target with a big if/else to check what platform the build is running on?
will check in #ktor as well. Thanks in any case.
r
Oh I see. You might need to build that target on Linux in that case. I've never tried to link a library from a different native platform.
j
I'm just trying to make
gradle build
not fail. Including the linux targets means the build fails on my mac. The windows build is not a problem somehow.