i am trying to build a mingw64 binary on linux, as...
# kotlin-native
n
i am trying to build a mingw64 binary on linux, as kotlin 1.6.0 shopuld support that now, but i also use ktor in there and am not sure which dependency i am missing to make it link libcurl
Copy code
> Task :linkReleaseExecutableMingwX64 FAILED
e: /home/nikky/.konan/dependencies/llvm-11.1.0-linux-x64-essentials/bin/clang++ invocation reported errors

The /home/nikky/.konan/dependencies/llvm-11.1.0-linux-x64-essentials/bin/clang++ command returned non-zero exit code: 1.
output:
lld: error: unable to find library -lcurl
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
anyone got this to work yet ?
m
Looks like you need libcurl-dev installed on your host system?
Well which obvisously will not work for cross compilation 🤦‍♂️
I'm super curious about the answer. I always found the dynamic linking fragile
h
on macOS it works: building mingw as well as linux
m
For linking statically you have to replace
-lcurl
to something like https://github.com/msink/hello-curl/blob/20a84a95d32d8fe2df2e5ccc998c83f64e868e28/build.gradle.kts#L35 And then - download bunch of .a files from https://github.com/msink/hello-curl/tree/main/bundle/2021-06-02/mingw64/lib and place them somewhere available in
-L
path. Didn't try it myself, but in theory should work.
n
so.. i need to specify all of that even though KTOR should have all of it already ?
m
AFAIK (didn't try myself) - for now application with KTOR curl backend for windows will need all (or most) of them in runtime, as .dll If linked statically - as described above - resulting .exe will be standalone.
m
There was an issue about linking curl statically in Ktor but I can't find it anymore
h
Ktor does not have them already, and won't have it statically: https://youtrack.jetbrains.com/issue/KTOR-2186
m
Hey, we're not going to link curl statically cause of the distribution size and compatibility issues.
Really just opposite - there WILL BE compatibility issues until curl will be linked statically. In particular - application linking will be possible only on windows host.
m
Ah yes, that was the issue. I didn't find it because it was closed :-(
Linking statically is also useful to run on super small docker images that might not have libcurl-dev all the time...
n
seems like a bit of sidetracking.. i am trying to get it to (cross) compile at all right now.. dynamically or statically i honestly don't care .. .. not like i am managing to get it to compile from windows either.. its a mess
👍 1