尝试从源代码构建 pango (1.34.1) 和 harfbuzz (0.9.18) 时出错

尝试从源代码构建 pango (1.34.1) 和 harfbuzz (0.9.18) 时出错

所以我试图从源代码构建pango(在我的主目录中,作为对我需要的其他东西的依赖)。这是在运行 SLES 11 的计算集群上。编译时,出现以下错误:

...
Making all in examples
make[2]: Entering directory `/usr/people/xxxx/downloads/pango-1.34.1/examples'
  CC       cairosimple.o
  CCLD     cairosimple
/usr/people/xxxx/local/lib/libharfbuzz.so: undefined reference to `FT_Get_Advance'
collect2: ld returned 1 exit status
make[2]: *** [cairosimple] Error 1
make[2]: Leaving directory `/usr/people/xxxx/downloads/pango-1.34.1/examples'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/people/xxxx/downloads/pango-1.34.1'
make: *** [all] Error 2

检查 libharfbuzz.so 上的链接依赖关系给出以下信息:

ldd ~/local/lib/libharfbuzz.so

...
libfreetype.so.6 => /usr/people/xxxx/local/lib/libfreetype.so.6 (0x00007f2323b0f000)

更进一步,在 libfreetype.so (我也是从源代码安装的)上运行 objdump 我得到:

objdump -T ~/local/lib/libfreetype.so.6 | objdump -T ~/local/lib/libfreetype.so.6 grep FT_Get_Advance

00000000000148f0 g    DF .text  0000000000000152  Base        FT_Get_Advance
0000000000014700 g    DF .text  00000000000001ed  Base        FT_Get_Advances

尽管系统上安装的版本在 /usr/lib/ (我没有 root 访问权限)中,但没有引用 FT_Get_Advance。

看起来代码在某个地方引用了全局库,尽管我似乎找不到哪里。有人有主意吗?

编辑:我刚刚在 libharfbuzz.so 上运行了 objdump(来自我的主目录中安装的版本),似乎有许多对 freetype 和 GLIBC 的未定义引用......那么我编译 harfbuzz 的方式有什么问题?

objdump -T libharfbuzz.so | objdump -T libharfbuzz.so | grep *UND*

0000000000000000      DF *UND*  0000000000000000              FT_Get_Advance
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 mprotect
0000000000000000      DF *UND*  0000000000000000              FT_Load_Sfnt_Table
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 memset
0000000000000000      DF *UND*  0000000000000000              FT_Set_Char_Size
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 snprintf
0000000000000000      DF *UND*  0000000000000000              FT_Select_Charmap
0000000000000000      DF *UND*  0000000000000000              g_intern_static_string
0000000000000000      DF *UND*  0000000000000000              g_unichar_combining_class
0000000000000000      DF *UND*  0000000000000000              FT_Load_Glyph
0000000000000000  w   D  *UND*  0000000000000000              __gmon_start__
0000000000000000  w   D  *UND*  0000000000000000              _Jv_RegisterClasses
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 __assert_fail
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strncmp
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 malloc
0000000000000000      DF *UND*  0000000000000000             g_unicode_script_to_iso15924
0000000000000000      DF *UND*  0000000000000000              FT_Done_FreeType
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 __cxa_atexit
0000000000000000      DF *UND*  0000000000000000              g_unichar_get_mirror_char
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 sysconf
0000000000000000      DF *UND*  0000000000000000              g_unichar_compose
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 pthread_mutex_init
0000000000000000      DF *UND*  0000000000000000              g_unicode_script_from_iso15924
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 free
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strlen
0000000000000000      DF *UND*  0000000000000000                FT_Face_GetCharVariantIndex
0000000000000000  w   DF *UND*  0000000000000000  GLIBC_2.2.5 __cxa_finalize
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 bsearch
0000000000000000      DF *UND*  0000000000000000              FT_Get_Name_Index
0000000000000000      DF *UND*  0000000000000000              FT_Get_Kerning
0000000000000000      DF *UND*  0000000000000000              g_unichar_decompose
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strerror
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strstr
0000000000000000      DF *UND*  0000000000000000              g_unichar_type
0000000000000000      DF *UND*  0000000000000000              FT_Init_FreeType
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strtol
0000000000000000      DF *UND*  0000000000000000              g_unichar_iswide
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 memcpy
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 memmove
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strchr
0000000000000000      DF *UND*  0000000000000000              g_unichar_get_script
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 getenv
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 __errno_location
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 qsort
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strdup
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strcmp
0000000000000000      DF *UND*  0000000000000000              FT_New_Memory_Face
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 calloc
0000000000000000      DF *UND*  0000000000000000              FT_Get_Char_Index
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strncpy
0000000000000000      DF *UND*  0000000000000000              g_once_init_enter
0000000000000000      DF *UND*  0000000000000000              FT_Get_Glyph_Name
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 pthread_mutex_lock
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 realloc
0000000000000000      DF *UND*  0000000000000000              FT_Done_Face
0000000000000000      DF *UND*  0000000000000000              g_once_init_leave
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 setlocale
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 pthread_mutex_destroy
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strtoul
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 pthread_mutex_unlock
0000000000000000      DF *UND*  0000000000000000              g_unichar_fully_decompose
0000000000000000      DF *UND*  0000000000000000              g_boxed_type_register_static

答案1

2 件事:

1) Harfbuzz 和 FreeType 显然有一个臭名昭著的循环依赖。这意味着您确实需要在与系统库完全隔离的地方对两者进行自己的构建。

2) 根据经验,GCC 构建工具将在您自己的任何自定义构建之前找到系统库(例如通过 pkgconfig、FindXXX.cmake、环境变量等),除非您明确告诉它们首先查看您的系统库。毕竟,这是他们瞄准的主要用例。检查您的 CMakeLists.txt 或 Makefile 是否在您的 FreeType 版本(而不是任何操作系统版本)中显式链接。听起来你的构建首先找到操作系统,然后(错误地)尝试使用它。

要测试您是否获得了正确的 FreeType,您可以备份您的 FreeType,然后更改主要版本#。重新运行构建,然后在 libharfbuzz.so 的构建上运行“ldd”或“readelf -d”,并确认您看到链接的 Freetype 的正确版本。

顺便说一句,要构建 Pango 以使用 Harfbuzz,操作顺序似乎是:
A) 构建“普通”FreeType
B) 构建 Harfbuzz
C) 使用 Harfbuzz 构建新的 Freetype
D) 最后,在步骤 (C) 中使用 FreeType 构建 Pango ,明确加上 Harfbuzz。

我还没有尝试过,但这就是各种说明给我的指示。除非您确定需要它,否则我可能会完全放弃 Harfbuzz,因为引入它似乎也意味着重建 FreeType。

相关内容