我无法在 alpine edge 下构建 crystal 程序的静态二进制文件
I can't build static binary of crystal program under alpine edge
我正在尝试编译最简单的 crystal 程序,但带有 --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
- 没有运气 - 它与包裹有关,还是我遗漏了什么?
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
我已经在全新的 alpine 容器上对此进行了测试。
缺少libgc, but this is required by the Crystal package in the repo (if you installed Crystal from there). You might need the dev version though, as noted in the docs。
答案似乎是 gc-dev
不再提供 edge
上的静态库。这曾经是这种情况,并且在 3.9
.
之前的版本中仍然如此
有一个 PR 可以解决这个问题:https://github.com/alpinelinux/aports/pull/6970
我正在尝试编译最简单的 crystal 程序,但带有 --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
- 没有运气 - 它与包裹有关,还是我遗漏了什么?
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
我已经在全新的 alpine 容器上对此进行了测试。
缺少libgc, but this is required by the Crystal package in the repo (if you installed Crystal from there). You might need the dev version though, as noted in the docs。
答案似乎是 gc-dev
不再提供 edge
上的静态库。这曾经是这种情况,并且在 3.9
.
有一个 PR 可以解决这个问题:https://github.com/alpinelinux/aports/pull/6970