【问题标题】:gcc can't find `FT_Error_String` when trying to compilegcc在尝试编译时找不到`FT_Error_String`
【发布时间】:2020-05-06 17:24:40
【问题描述】:


我正在尝试编译一个使用 freetype2 的应用程序,我从官方网站下载并编译了最新版本的 freetype2
我使用这个命令编译程序:

gcc ttf2sfn.c -I/home/emilia/os/freetype-2.10.1/include -L/home/emilia/os/freetype-2.10.1/objs -lfreetype

但是,链接器找不到“FT_Error_String”字符。
它打印此错误消息:

/tmp/cc6FGxyc.o: In function `main':
ttf2sfn.c:(.text+0x25aa): undefined reference to `FT_Error_String'
ttf2sfn.c:(.text+0x352c): undefined reference to `FT_Error_String'
collect2: error: ld returned 1 exit status

为什么会这样? 谢谢。

【问题讨论】:

    标签: c gcc freetype freetype2


    【解决方案1】:

    它似乎并不实际存在。我使用我自己的函数 ftstrerror 来做一些等效的事情:

    static const char *ftstrerror(FT_Error error)
    {
    #undef FTERRORS_H_
    #define FT_ERRORDEF(error_code, value, string) case error_code: return string;
    #define FT_ERROR_START_LIST switch(error) {
    #define FT_ERROR_END_LIST default: return "Unknown error"; }
    #include FT_ERRORS_H
    }
    

    【讨论】:

      【解决方案2】:

      [用 FreeType 2.10.3 测试。] 你一定做错了什么。 FT_Error_String始终定义的。但是,仅当库已配置(在构建时)设置了宏 FT_CONFIG_OPTION_ERROR_STRINGS 时,它才会返回非 NULL 值。由于默认关闭,您必须在文件 include/freetype/config/ftoption.h 中显式启用此功能。

      【讨论】:

        猜你喜欢
        • 2021-07-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-25
        • 2019-08-29
        • 2015-09-29
        • 1970-01-01
        相关资源
        最近更新 更多