Chlumsky / msdf-atlas-gen

MSDF font atlas generator
MIT License
783 stars 175 forks source link

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

Closed maladr0it closed 1 year ago

maladr0it commented 2 years ago

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.

andreypopp commented 2 years ago

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

Chlumsky commented 1 year ago

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