title: Building Qt for Linux x86 with fontconfig support
body: <p>I'm porting my Qt app to Linux for x86 architecture, and since the last official release for that platform is 5.5, I'm trying to do my own build of Qt 5.11.3. I want to use fontconfig to enable use of system fonts. My build platform is Centos 7.5, and I'm using a GCC toolchain which builds x86 binaries with -m32 switch.
  The problem is, I can't get it to see the fontconfig library. I've installed it with the package fontconfig-devel-2.13.0-4.3.el7.i686</p>
  
  <p>When running configure with the option -fontconfig, I get the following error message:</p>
  
  <blockquote>
    <p>ERROR: Feature 'fontconfig' was enabled, but the pre-condition '!config.win32 &amp;&amp; features.system-freetype &amp;&amp; libs.fontconfig' failed.</p>
  </blockquote>
  
  <p>My understanding from this is that I have to use -system-freetype and can't use -qt-freetype, but when I try that (also with -feature-freetype), I get this message:</p>
  
  <blockquote>
    <p>ERROR: Feature 'system-freetype' was enabled, but the pre-condition 'features.freetype &amp;&amp; libs.freetype' failed.</p>
  </blockquote>
  
  <p>The relevant messages in config.log are:</p>
  
  <pre><code>looking for library freetype
  Trying source 0 (type pkgConfig) of library freetype ...
  pkg-config use disabled globally.
    =&gt; source produced no result.
  Trying source 1 (type freetype) of library freetype ...
  + cd /home/myuser/qt-build/config.tests/freetype &amp;&amp; /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 &amp;&amp; MAKEFLAGS= /usr/bin/gmake
  &gt; 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
  &gt; main.cpp:2:22: fatal error: ft2build.h: No such file or directory
  &gt;  #include &lt;ft2build.h&gt;
  &gt;                       ^
  &gt; compilation terminated.
  &gt; gmake: *** [main.o] Error 1
   =&gt; source failed verification.
  test config.qtbase_gui.libraries.freetype FAILED
  </code></pre>
  
  <p>Now, I do also get this message:</p>
  
  <blockquote>
    <p>WARNING: Cross compiling without sysroot. Disabling pkg-config</p>
  </blockquote>
  
  <p>which I understand is the source of the "source 0" failure. I have however tried to point configure manually point it to the freetype include directory, by passing FREETYPE_INCDIR=/usr/include/freetype2 to configure; however, as can be seen in the log file, the value does not seem to be used when detecting freetype.</p>
  
  <p>Am I missing a trick here, or are the configure scripts broken? And if it's the latter, is there a way to work around this?</p>
  
  <p>EDIT: For completeness, the environment for running configure:</p>
  
  <pre><code>CFLAGS=-m32
  CXXFLAGS=-m32 --std=c++1x
  </code></pre>
  
  <p>Configure flags:</p>
  
  <pre><code>-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
  </code></pre>