Crystal: required libraries for compilation on arch?

Created on 13 Jun 2018  路  7Comments  路  Source: crystal-lang/crystal

This page https://github.com/crystal-lang/crystal/wiki/All-required-libraries has directions for Ubuntu, Fedora, and OSX. Does anyone know what is required for Arch? I'm having some issues compiling with --static and I suspect there might be some libraries I need that I don't have.

$ crystal build src/hello_world.cr --release --static
/usr/bin/ld: cannot find -lpcre
/usr/bin/ld: cannot find -lgc
/usr/bin/ld: cannot find -levent
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/sam/Desktop/workspace/crystal-gcf-concept/hello_world'  -rdynamic -static  -lpcre -lgc -lpthread /usr/lib/crystal/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`

Most helpful comment

thanks a bunch guys -- a docker image is perfect for my needs

All 7 comments

Ok so I have no idea why pcre, gc, and libevent are giving me problems as I have all of them. I installed crystal via pacman so I have 0.24.2. :thinking:

This same compilation works on Ubuntu, so it's definitely something about arch or at least about my system

@sam0x17 the .a archives required for static compilation aren't provided.

The best is to use a musl-based distribution like alpine. You can use this docker image (maybe I can add an entry in the wiki though).

There are lots of issues related to static compilation. Problems related to the distribution packages, their versions, or the meaning of the linking error.

What about suggesting an "official" solution for static linking like a Docker image to solve this when --static fails (lile we are going to do with macOS?

static compilation isn't supported by archlinux, either for C or Crystal. You'll have to compile static libraries yourself if you want them. The only sane environment for static linking is musl, the rest of linux is broken.

thanks a bunch guys -- a docker image is perfect for my needs

Adding to the above, if you're looking at distribution, AppImages are basically static linking but better, and there's always the Flatpak and Snap app stores.

@kirbyfan64 thanks for the tip -- in my case I am limited by what Google has pre-installed on their cloud functions VM, which definitely does not include flatpack or snap, but I might be able to do this another way using a disposable docker image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pbrusco picture pbrusco  路  3Comments

jhass picture jhass  路  3Comments

asterite picture asterite  路  3Comments

TechMagister picture TechMagister  路  3Comments

oprypin picture oprypin  路  3Comments