我正在尝试编译最简单的水晶程序,但使用--static
标志:
代码:
# x.cr
puts "test"
汇编:
crystal build --static x.cr
结果:
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lgc (this usually means you need to install the development package for libgc)
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/app/x' -rdynamic -static /usr/lib/libpcre.a -lgc /usr/lib/libpthread.a /usr/lib/crystal/core/ext/libcrystal.a /usr/lib/libevent.a /usr/lib/librt.a -L/usr/lib -L/usr/local/lib`
我猜我错过了一些apk
包。我试过gc
,gc-dev
,musl-dev
- 没有运气 - 它与包有关系,还是我错过了什么?
答案似乎是gc-dev
不再在edge
上提供静态库。过去是这种情况,仍然是在3.9
发布。
有一个公关来解决这个问题:https://github.com/alpinelinux/aports/pull/6970
apk add crystal shards
# equivalent to build-essentials
apk add --virtual build-dependencies build-base gcc
# or a more complete build dependencies pkg:
# apk add --update alpine-sdk
crystal build --static x.cr
我在一个新的高山容器上进行了测试。