https://kotlinlang.org logo
#ktor
Title
# ktor
j

Jilles van Gurp

10/21/2023, 10:58 AM
Some more details on the issue I posted a few days ago. I'm trying to use the curl engine for ktor client in a multi platform project (kt-search) and I'm having issues with running this on multi platform builds on my m1 mac and kotlin 1.9.20-RC. Curl seems to be broken for Linux builds. Several issues that I'm working around: 1. with home brew curl installed, I get a linking error during linkDebugTestMacosX64. Solution: brew remove curl. The mac build works fine without this. 1. The linux targets don't build on mac with some linking error on x86 and curl can't be found at all for arm64 I work around that with an if on the operating system:
Copy code
kotlin
jvm {
}
js(IR) {
    browser {
        testTask(Action {
            useMocha {
                // javascript is a lot slower than Java, we hit the default timeout of 2000
                timeout = "30s"
            }
        })
    }
    nodejs {
        testTask(Action {
            useMocha {
                // javascript is a lot slower than Java, we hit the default timeout of 2000
                timeout = "30s"
            }
        })
    }
}
// only enable the linux targets when building on linux
// some issues with linux lib curl availability on other platforms
if(DefaultNativePlatform.getCurrentOperatingSystem().isLinux) {
    // some weird linking error
    linuxX64()
    // lib curl is not found for this one :-(
    linuxArm64()
}
mingwX64()
macosX64()
macosArm64()
1. On github actions the linux build fails with a different error:
Copy code
> Task :search-client:linkDebugTestLinuxX64 FAILED
e: /home/runner/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold invocation reported errors

The /home/runner/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold command returned non-zero exit code: 1.
output:
/home/runner/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold: error: cannot find -lcurl
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_global_init_wrapper23: error: undefined reference to 'curl_global_init'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_slist_append_wrapper27: error: undefined reference to 'curl_slist_append'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_slist_free_all_wrapper28: error: undefined reference to 'curl_slist_free_all'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_easy_strerror_wrapper33: error: undefined reference to 'curl_easy_strerror'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_easy_pause_wrapper35: error: undefined reference to 'curl_easy_pause'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_easy_init_wrapper36: error: undefined reference to 'curl_easy_init'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_easy_cleanup_wrapper38: error: undefined reference to 'curl_easy_cleanup'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_init_wrapper44: error: undefined reference to 'curl_multi_init'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_add_handle_wrapper45: error: undefined reference to 'curl_multi_add_handle'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_remove_handle_wrapper46: error: undefined reference to 'curl_multi_remove_handle'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_poll_wrapper49: error: undefined reference to 'curl_multi_poll'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_wakeup_wrapper50: error: undefined reference to 'curl_multi_wakeup'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_perform_wrapper51: error: undefined reference to 'curl_multi_perform'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_cleanup_wrapper52: error: undefined reference to 'curl_multi_cleanup'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_info_read_wrapper53: error: undefined reference to 'curl_multi_info_read'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:function libcurl_curl_multi_strerror_wrapper54: error: undefined reference to 'curl_multi_strerror'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:knifunptr_libcurl39_curl_easy_setopt: error: undefined reference to 'curl_easy_setopt'
/tmp/konan_temp6861980240265917513/test.kexe.o:out:knifunptr_libcurl42_curl_easy_getinfo: error: undefined reference to 'curl_easy_getinfo'
So, my conclusion so far is that the Curl engine simply doesn't work on Linux. Is this correct or is there something else I need to do to get this working? My impression is that curl in the konan instal is just broken for linux. If you want to have a go at this, please use the more-multi-platform-targets branch on kt-search. The search-client module is the one that I'm having issues with.
🧵 1
a

Aleksei Tirman [JB]

10/23/2023, 6:41 AM
Can you please file an issue?