c++g++freetypefreetype2

fatal error: freetype/config/ftheader.h


I am trying to use freeglut2 for rendering text in OpenGL. When I included the following header,

#include <freetype2/ft2build.h>

it gives the following error :

/usr/local/include/freetype2/ft2build.h:37:38: fatal error: freetype/config/ftheader.h: No such file or directory

But when I go to /usr/local/include/freetype2/freetype/config , I found the file ftheader.h.

Please help me in figuring out the issue. Thank you.

I went to the this but nothing worked.


Solution

  • Your compiler searches for includes in /usr/local/include, so when you do:

    #include <freetype2/ft2build.h>
    

    it finds /usr/local/include/freetype2/ft2build.h

    but this file tries to include freetype/config/ftheader.h and there is no

    /usr/local/include/freetype/config/ftheader.h
    

    but

    /usr/local/include/freetyp2/freetype/config/ftheader.h
    

    So you shall pass -I/usr/local/include/freetyp2 to your compiler and do a

    #include <ft2build.h>
    

    to be correct.

    If your system supports it - use pkg-config utility, which can provide all compilations flag, e.g.:

    $ pkg-config --cflags freetype2
    -I/usr/include/freetype2  
    
    $ pkg-config --libs freetype2
    -lfreetype