font-kit icon indicating copy to clipboard operation
font-kit copied to clipboard

Support statically linking against fontconfig and FreeType

Open JonnyWalker81 opened this issue 5 years ago • 2 comments

Does font-kit support being built in Docker using the rust-musl-bulider? I am trying to produce a fully static binary to be used on an Alpine Linux image. I am currently unable to get my application to build when I include font-kit as a dependency. Any help you can offer would be greatly appreciated.

The executable seems to build, but it seems to be dynamically linking against libfontconfig and libfreetype, here is the output of ldd from the docker image:

/usr/local/bin # ldd optimus-prime
        /lib/ld64.so.1 (0x7fe47f989000)
Error loading shared library libfontconfig.so.1: No such file or directory (needed by optimus-prime)
Error loading shared library libfreetype.so.6: No such file or directory (needed by optimus-prime)
Error relocating optimus-prime: FT_Init_FreeType: symbol not found
Error relocating optimus-prime: FcObjectSetCreate: symbol not found
Error relocating optimus-prime: FcPatternDestroy: symbol not found
Error relocating optimus-prime: FT_Set_Char_Size: symbol not found
Error relocating optimus-prime: FcPatternGetInteger: symbol not found
Error relocating optimus-prime: FcPatternCreate: symbol not found
Error relocating optimus-prime: FcInitLoadConfigAndFonts: symbol not found
Error relocating optimus-prime: FcPatternAddString: symbol not found
Error relocating optimus-prime: FT_Done_Face: symbol not found
Error relocating optimus-prime: FcObjectSetDestroy: symbol not found
Error relocating optimus-prime: FT_New_Memory_Face: symbol not found
Error relocating optimus-prime: FcPatternGetString: symbol not found
Error relocating optimus-prime: FcObjectSetAdd: symbol not found
Error relocating optimus-prime: FcFontList: symbol not found
Error relocating optimus-prime: FcFontSetDestroy: symbol not found

@pcwalton

JonnyWalker81 avatar Jan 07 '20 23:01 JonnyWalker81

This seems like more of an issue for https://github.com/servo/rust-fontconfig and https://github.com/servo/rust-freetype. Specifically, you will need them to support static linking, perhaps via a Cargo feature.

pcwalton avatar Jan 14 '20 19:01 pcwalton

I have a hard time trying to cross-compile to ARMv8 from Windows because of freetype, for which it doesn't find the library:

error: could not find native static library freetype, perhaps an -L flag is missing?

It seems related to this issue.

blueglyph avatar Jun 12 '22 15:06 blueglyph