致命错误:freetype/config/ftheader.h

fatal error: freetype/config/ftheader.h

本文关键字:ftheader config 致命错误 freetype      更新时间:2023-10-16

我正在尝试使用 freeglut2 在 OpenGL 中渲染文本。当我包含以下标题时,

#include <freetype2/ft2build.h>

它给出以下错误:

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

但是当我去/usr/local/include/freetype2/freetype/config时,我找到了文件ftheader.h。

请帮助我找出问题。谢谢。

我去了这个,但没有任何效果。

编译器在

/usr/local/include 中搜索包含,因此当您执行以下操作时:

#include <freetype2/ft2build.h>

它找到了/usr/local/include/freetype2/ft2build.h

但是这个文件试图包含freetype/config/ftheader.h并且没有

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

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

因此,您应该将-I/usr/local/include/freetyp2传递给编译器并执行

#include <ft2build.h>

是正确的。

如果您的系统支持它 - 使用pkg-config实用程序,它可以提供所有编译标志,例如:

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

阅读本文档: http://freetype.org/freetype2/docs/tutorial/step1.html#section-1

您需要将/usr/local/include/freetype2 添加到包含路径中。

然后你包括ft2build.h:

#include <ft2build.h>

然后,当ft2build.h包含freetype/config/ftheader.h时,它将在包含路径中的freetype2目录中查找并找到它。