Chlumsky/msdf-atlas-gen

Cannot build on m1 macbook, 'tf2build.h' not found

Closed this issue · 2 comments

On an m1 macbook, I cloned the repository recursively, and ran make

The following error is printed

msdfgen/ext/import-font.cpp:6:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
         ^~~~~~~~~~~~
1 error generated.

Using the cmake GUI, it reports to me:

Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)

I have tried installing freetype via brew install freetype, and modifying the Makefile to point freetype like so:

-I /opt/homebrew/include/freetype2

This instead produces the error:

ld: library not found for -lfreetype
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I believe macOS should already include the freetype library anyway.

I have successfully built this library on other macOS machines, so I'm not sure if I'm doing something wrong or there is something unique about my setup that is causing this issue.

This is linker error you are hitting, the fix would be to pass -Lpath flag as well, here's the patch which uses pkg-config to query for include and lib flags (works on m1 MacBook with new homebrew layout):

https://gist.github.com/andreypopp/c5588c51ca207d48a22ccf6b3013e5ff

The build now requires CMake and has been overhauled. Please reopen if the issue persists.