I push my first hello world crystal shards to github today.
the main purpose for this shard is to write a github action, to build a static version binary, automatically, when i push a tag into github, then i can download from there to use anywhere (linux only)
because i found many famous shards in github never use this automate process, so i share my action file here.
Almost just copy from our gh-actions document, with a little improvement for do release and create a tarball, it good to as a start point anyway.
There is one more question, from [document](Static Linking - Crystal]., i saw this:
With pre-installed crystal compiler, shards, and static libraries of all of stdlib's dependencies these Docker images allow to easily build static Crystal binaries even from glibc-based systems. The official Crystal compiler builds for Linux are created using these images.
so, i consider build static binary directly from normal distro (e.g. i use arch linux) is possible nowaday, right?
The context is, i installed musl packages correctly, i can build several C program binary use make
like make LDFLAGS=-static CC=musl-gcc
successful, i even can build some rust package e.g. famous fd successful use following command.
$: cargo build --target x86_64-unknown-linux-musl --release
But, i don’t know how to do this with Crystal, there are some discuss several years ago,
maybe it time to open a new thread for discuss this, so, in fact when i try to build on my own distro, i get following error msg:
╰─ $ 130 CC=musl-gcc shards build --production --release --progress --static --no-debug --link-flags="-s -Wl,-z,relro,-z,now"
Dependencies are satisfied
Building: crystal_hello_world
Error target crystal_hello_world failed to compile:
/usr/sbin/ld: cannot find -lpcre (this usually means you need to install the development package for libpcre): No such file or directory
/usr/sbin/ld: cannot find -levent (this usually means you need to install the development package for libevent): No such file or directory
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `musl-gcc "${@}" -o /home/common/Study/Crystal/crystal_hello_world/bin/crystal_hello_world -s -Wl,-z,relro,-z,now -rdynamic -static -L/home/zw963/Crystal/bin/../lib/crystal -lpcre -lm -lgc -lpthread -levent -lrt -lpthread -ldl`
could anyone help on how to resolve this?
Thank you.