The Crystal Programming Language Forum

Static linking with libxml2

Alpine has added xz as a dependency of libxml2.

I added xz-dev to the dependencies (in fact it is installed automatically), but there is still a linking issue:

Minimal example to reproduce on Alpine Edge (you can use the jrei/crystal-alpine:edge Docker image):

echo 'require "xml"' >
crystal build --static

I think it may be an issue with pkg-config (on the Crystal side or Alpine), because I don’t see any lzma in the cc linking command.

pkg-config libxml-2.0 --libs --static returns -lxml2 -L/lib -lz -llzma -lm

Manually passing --link-flags '-lzma -lxml2' do the trick.


I guess we can add that to the @[Link(...)] thing on our side then, for alpine?

There is no way to use pkg-config for this? How do we know we are on Alpine, at Edge, using the official package?