Search code examples
c++freetype

Installed freetype through homebrew, can't seem to include headers correctly


On my xcode project, I added the dylib of freetype to the project Link Binary phase.

I ensure /usr/local/include and /usr/local/lib are in search paths in the build settings.

I then include:

#include <freetype2/ft2build.h>
#include FT_FREETYPE_H

But i get an error that freetype.h was not found. Any ideas? I tried including <freetype2/freetype.h> directly, but that leads to more compile problems with include paths in other freetype files.


Solution

  • Looking at the demo programs in "freetype2-demos", I see:

    #include <ft2build.h>
    #include FT_FREETYPE_H
    

    Also, I think you need your compiler command-line to include -I (path to freetype includes).

    For example...

    g++ -I (...)/freetype2 myfile.cpp
    

    Here are the instructions. The suggestion there is to compile with something like...

    g++ $(freetype-config --cflags) myfile.cpp
    

    ...which, if you system is configured correctly, will incorporate the -I option that I previously mentioned.