使用fontconfig支持为Linux x86构建Qt

时间:2018-12-12 14:30:05

标签: qt qt5

我正在将我的Qt应用程序移植到用于x86架构的Linux上,并且由于该平台的最新正式版本是5.5,所以我正在尝试构建自己的Qt 5.11.3。我想使用fontconfig启用系统字体的使用。我的构建平台是Centos 7.5,我使用的是GCC工具链,该工具链使用-m32开关构建x86二进制文件。 问题是,我无法看到fontconfig库。我已经用package fontconfig-devel-2.13.0-4.3.el7.i686包安装了它

使用-fontconfig选项运行configure时,出现以下错误消息:

  

错误:功能'fontconfig'已启用,但前提条件'!config.win32 && features.system-freetype && libs.fontconfig'失败。

我的理解是,我必须使用-system-freetype,不能使用-qt-freetype,但是当我尝试使用该功能时(也使用-feature-freetype),我得到以下消息:

  

错误:功能'system-freetype'已启用,但前提条件'features.freetype && libs.freetype'失败。

config.log中的相关消息是:

looking for library freetype
Trying source 0 (type pkgConfig) of library freetype ...
pkg-config use disabled globally.
  => source produced no result.
Trying source 1 (type freetype) of library freetype ...
+ cd /home/myuser/qt-build/config.tests/freetype && /home/myuser/qt-build/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" -early "CONFIG += cross_compile" 'LIBS += -lfreetype' /home/myuser/qt-build/config.tests/freetype
+ cd /home/myuser/qt-build/config.tests/freetype && MAKEFLAGS= /usr/bin/gmake
> g++ -c -m32 -pipe -O2 -std=gnu++11 -w -fPIC  -I. -I/home/myuser/qt-everywhere-src-5.11.3/qtbase/mkspecs/linux-g++-32 -o main.o main.cpp
> main.cpp:2:22: fatal error: ft2build.h: No such file or directory
>  #include <ft2build.h>
>                       ^
> compilation terminated.
> gmake: *** [main.o] Error 1
 => source failed verification.
test config.qtbase_gui.libraries.freetype FAILED

现在,我也收到此消息:

  

警告:不使用sysroot进行交叉编译。禁用pkg-config

我理解的

是“源0”故障的根源。但是,我试图通过传递FREETYPE_INCDIR = / usr / include / freetype2进行配置,以手动将其指向freetype include目录。但是,从日志文件中可以看出,检测自由类型时似乎未使用该值。

我在这里缺少技巧吗,还是配置脚本损坏了?如果是后者,是否有解决方法?

编辑:为完整起见,运行配置的环境:

CFLAGS=-m32
CXXFLAGS=-m32 --std=c++1x

配置标志:

-opensource
-xplatform linux-g++-32
-nomake tests -nomake examples -nomake tools
-prefix /home/myuser/qt_install/
-qpa xcb
-no-use-gold-linker
-icu ICU_PREFIX=/home/myuser/icu_install ICU_LIBS="-licui18n -licuuc -licudata"
-no-opengl
-fontconfig -feature-freetype -system-freetype FREETYPE_INCDIR=/usr/include/freetype2

2 个答案:

答案 0 :(得分:1)

我发现可以通过设置CPATH(和LIBRARY_PATH指向我也需要的特定Freetype构建)来解决此问题。看来,检测到Freetype的存在时会忽略FREETYPE_ *变量确实是配置脚本中的错误。

答案 1 :(得分:0)

尝试使用Qt来源中包含的Freetype库:运行configure时,请使用标志“ -qt-freetype