Reputation: 121
I'm trying to compile simplest crystal program, but with --static
flag:
The code:
# x.cr
puts "test"
Compilation:
crystal build --static x.cr
The result:
/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`
I'm guessing I'm missing some apk
package. I tried gc
, gc-dev
, musl-dev
- no luck - Is it package related, or am I missing something?
Upvotes: 2
Views: 1751
Reputation: 5661
The answer seems to be that gc-dev
doesn't provide a static library on edge
any more. This used to be the case and still is in releases up to 3.9
.
There is a PR to fix that: https://github.com/alpinelinux/aports/pull/6970
Upvotes: 2
Reputation: 188
It is missing 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.
Upvotes: 0
Reputation: 10107
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
I've tested this on a fresh new alpine container.
Upvotes: 1