K
Kord2mo ago
vyfor

[Kotlin/Native] Linking stage fails

I've spent days trying to figure out this issue, and it turns out that the build fails whenever I explicitly specify a Ktor engine. The Kord native build fails on linux (irrelevant of dependencies) with the following error:
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:
/tmp/konan_temp5888808197062752774/kord-test.kexe.o:out:function libcurl_curl_ws_send_wrapper76: error: undefined reference to 'curl_ws_send'
/tmp/konan_temp5888808197062752774/kord-test.kexe.o:out:function libcurl_curl_ws_meta_wrapper77: error: undefined reference to 'curl_ws_meta'
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:
/tmp/konan_temp5888808197062752774/kord-test.kexe.o:out:function libcurl_curl_ws_send_wrapper76: error: undefined reference to 'curl_ws_send'
/tmp/konan_temp5888808197062752774/kord-test.kexe.o:out:function libcurl_curl_ws_meta_wrapper77: error: undefined reference to 'curl_ws_meta'
37 Replies
vyfor
vyfor2mo ago
windows build succeeds. minimal repro: https://github.com/vyfor/kord-test i think I need to build curl from source with websockets support. i copied a script that does just that, but now the linker is unable to find curl at all
SchlaubiBus
SchlaubiBus2mo ago
GitHub
setup-curl/action.yml at v1 · kordlib/setup-curl
Contribute to kordlib/setup-curl development by creating an account on GitHub.
SchlaubiBus
SchlaubiBus2mo ago
you can also find an example here
GitHub
GitHub - DRSchlaubi/alphabet: Test bot for Kord on Kotlin/JS and Ko...
Test bot for Kord on Kotlin/JS and Kotlin/Native. Contribute to DRSchlaubi/alphabet development by creating an account on GitHub.
vyfor
vyfor2mo ago
works like a charm, thank you ! hey, i'm new to Docker, and i tried using that Docker template, but i'm not sure how the application is built. i added my build command to the Dockerfile, but it's just skipping it, and in the end, it can't find the compiled application:
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 229B done
#1 DONE 0.0s
#2 [internal] load metadata for ghcr.io/kordlib/docker:main
#2 DONE 0.8s
#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s
#4 [internal] load build context
#4 transferring context: 2B done
#4 DONE 0.0s
#5 [2/4] WORKDIR /usr/app
#5 CACHED
#6 [3/4] RUN ./gradlew linuxX64MainBinaries --no-daemon
#6 CACHED
#7 [4/4] COPY build/bin/linuxX64/releaseExecutable/Yu.kexe /usr/app/bot
#7 ERROR: failed to calculate checksum of ref ...: "/build/bin/linuxX64/releaseExecutable/Yu.kexe": not found
#8 [1/4] FROM ghcr.io/kordlib/docker:main@sha256:c0ddc1a985f3ec5a8173d1874fdb1b2a462ae5ce7b0da148b212369b410f016e
#8 resolve ghcr.io/kordlib/docker:main@sha256:c0ddc1a985f3ec5a8173d1874fdb1b2a462ae5ce7b0da148b212369b410f016e done
#8 DONE 0.0s
------
> [4/4] COPY build/bin/linuxX64/releaseExecutable/Yu.kexe /usr/app/bot:
------
Dockerfile:5
--------------------
3 | WORKDIR /usr/app
4 | RUN ./gradlew linuxX64MainBinaries --no-daemon
5 | >>> COPY build/bin/linuxX64/releaseExecutable/Yu.kexe /usr/app/bot
6 |
7 | ENTRYPOINT ["/usr/app/bot"]
--------------------
error: failed to solve: failed to compute cache key: failed to calculate checksum of ref iqp39297sznk0a0ur6cmttkwd::7x6n37e3cthl222u0dws4c34f: "/build/bin/linuxX64/releaseExecutable/Yu.kexe": not found
exit status 1
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 229B done
#1 DONE 0.0s
#2 [internal] load metadata for ghcr.io/kordlib/docker:main
#2 DONE 0.8s
#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s
#4 [internal] load build context
#4 transferring context: 2B done
#4 DONE 0.0s
#5 [2/4] WORKDIR /usr/app
#5 CACHED
#6 [3/4] RUN ./gradlew linuxX64MainBinaries --no-daemon
#6 CACHED
#7 [4/4] COPY build/bin/linuxX64/releaseExecutable/Yu.kexe /usr/app/bot
#7 ERROR: failed to calculate checksum of ref ...: "/build/bin/linuxX64/releaseExecutable/Yu.kexe": not found
#8 [1/4] FROM ghcr.io/kordlib/docker:main@sha256:c0ddc1a985f3ec5a8173d1874fdb1b2a462ae5ce7b0da148b212369b410f016e
#8 resolve ghcr.io/kordlib/docker:main@sha256:c0ddc1a985f3ec5a8173d1874fdb1b2a462ae5ce7b0da148b212369b410f016e done
#8 DONE 0.0s
------
> [4/4] COPY build/bin/linuxX64/releaseExecutable/Yu.kexe /usr/app/bot:
------
Dockerfile:5
--------------------
3 | WORKDIR /usr/app
4 | RUN ./gradlew linuxX64MainBinaries --no-daemon
5 | >>> COPY build/bin/linuxX64/releaseExecutable/Yu.kexe /usr/app/bot
6 |
7 | ENTRYPOINT ["/usr/app/bot"]
--------------------
error: failed to solve: failed to compute cache key: failed to calculate checksum of ref iqp39297sznk0a0ur6cmttkwd::7x6n37e3cthl222u0dws4c34f: "/build/bin/linuxX64/releaseExecutable/Yu.kexe": not found
exit status 1
gdude
gdude2mo ago
Run the build outside of the container the copy command is for copying files from outside the container into it but you shouldn't build in the container b/c you'll be leaving all the development stuff in the layers alternatively, you can use docker to build, but don't use a dockerfile for that, use the docker command directly and map a volume between a local build directory and the target directory in the container but yeah really the canonical way to do this is to build outside of the container and then copy the result into it
vyfor
vyfor2mo ago
ohh right, that's how it works i'll give it a go
gdude
gdude2mo ago
there isn't really any good reason to build inside the container you can't run eg an ARM container on x64 anyway so do you want a bit more in-depth info?
vyfor
vyfor2mo ago
that'd be awesome
gdude
gdude2mo ago
so, containers are structured in a more complex way than you'd expect when you write a dockerfile, you're instructing the docker daemon on how to build the final container image but it actually creates a separate layer for each actionable command what that means is if, for example, you have a step running git, then a step downloading a toolchain, then a step building the project, then a step deleting the git files... each one of those is a layer docker has to download and deploy whenever you use the container, and those layers also have to be uploaded to your docker registry you really want to avoid doing that if you can the containers themselves run in a very light virtualisation layer that shares the kernel with the host OS which means you can't really cross-compile easily and the containers you're building and running will be specific to your machine's architecture tho these days that's really just ARM and x64 (there are others, but commonly)
vyfor
vyfor2mo ago
oh hmm i never realized that
gdude
gdude2mo ago
docker is a lot simpler in concept than most people expect then you have volumes, which allow you to map a path in a container to a mount of some sort often that'll be a bind mount to a path on the host, but not always the dockerfile won't contain a mapping, but you can still define the volumes you expect to exist but you probably don't need to worry about that right now
gdude
gdude2mo ago
this reference is pretty handy https://docs.docker.com/reference/dockerfile/
Docker Documentation
Dockerfile reference
Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more.
gdude
gdude2mo ago
and if you need to generate a dockerfile based on your project's data, I released this today https://docs.kordex.dev/docker-plugin
vyfor
vyfor2mo ago
gotcha! i've never had to deal with Docker before, i went for it as the hosting wouldn't allow me to do authorized stuff unless i used a container, though i found a workaround just now
gdude
gdude2mo ago
docker is very useful
Want results from more Discord servers?
Add your server