Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not sure when/if this changed recently, but from:

https://crystal-lang.org/docs/using_the_compiler/ "Creating a standalone executable":

crystal build some_program.cr --release --static

Builds a static binary (just tried it on Ubuntu 18.04 with a simple hello-world).



Thanks! These instructions seem to have less warnings than I saw last time, which implies it's more stable now.


You're going to have much better luck with an alpine-based docker image. Unfortunately non-musl based systems have a lot of issues with static compilation, so while this will work with hello world, if you try something more complicated you will likely get linker errors.


Particular to the c library? Because an "ldd" on the hello world listed quite a few libs which all worked fine with a static build.


openssl and libz are particularly fussy


I could definitely see openssl being tricky (libz not so much, but I might very well be naive here) - but how does changing the libc help with either?


glibc has some plugins which make it not easy to statically link. Musl doesn't have that. And alpine compiles openssl etc. with a config amenable to static linking. It's all about distro choices.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: