CentOS 5.2 + Qt 4.5 + FcFreeTypeQueryFace

So with all the buzz around the new release of Qt 4.5, you may be like me and have been desperately wanting to give it a whirl. Has this happened to you yet?

/opt/qtsdk-2009.01/qt/lib/libQtGui.so: undefined reference to `FcFreeTypeQueryFace'
collect2: ld returned 1 exit status

Someone’s got some ‘splainin to do. Lucky for you, that’s me. Basically, the people at fontconfig did not add this API call until 2.4.2. From fontconfig’s ChangeLog 2.4.2:

commit 72ffe6536a6825a32095c8185aff836a12326ac5
Author: Keith Packard 
Date:   Sat Dec 2 13:22:27 2006 -0800

    Add FcFreeTypeQueryFace external API. Bug #7311.
    
    Expose ability to build an FcPattern directly from an FT_Face
    object.

 configure.in            |    4 ++--
 doc/fcfreetype.fncs     |   17 +++++++++++++++-
 fontconfig/fcfreetype.h |    6 ++++++
 src/fcfreetype.c        |   50 ++++++++++++++++++++++++++---------------------
 4 files changed, 52 insertions(+), 25 deletions(-)

Problem is for us CentOS 5.2 users, we’re given a version 2.4.1-7 from “upstream” :( It’s not a big deal, we can just compile fontconfig from source … wait, did I just say compile? No worries, it’s easy.

1. Compile fontconfig 2.4.2 from source

Note: Throughout this step, I used fontconfig 2.4.2 since this is the minimum required version, but I tested this with the latest version 2.6.0 so just replace the version numbers accordingly if you choose to use 2.6.0.

[user@localhost ~]$ cd /usr/src
[user@localhost /usr/src]$ wget http://fontconfig.org/release/fontconfig-2.4.2.tar.gz
[user@localhost /usr/src]$ tar -zxf fontconfig-2.4.2.tar.gz
[user@localhost /usr/src]$ cd fontconfig-2.4.2
[user@localhost /usr/src/fontconfig-2.4.2]$ ./configure --prefix=/opt/fontconfig-2.4.2
... (note: 'configure' output omitted for brevity) ...
[user@localhost /usr/src/fontconfig-2.4.2]$ make
... (note: 'make' output omitted for brevity) ...
[user@localhost /usr/src/fontconfig-2.4.2]$ make install
... (note: 'make install' output omitted for brevity) ...

Note: I chose to install into /opt/fontconfig-2.4.2 since I like keeping my “deviations” from upstream organized.

2. Add the fontconfig library location to your project’s .pro file

LIBS += -L/opt/fontconfig-2.4.2/lib

3. Recompile and that’s it! 8-)

Now I can’t guarantee you will not have any ‘make’ errors due to library dependencies but I’m pretty sure that if you got as far as you did to receive this error, you will have every *-devel package needed by fontconfig already installed on your system.

About these ads

About theitdepartment
...

32 Responses to CentOS 5.2 + Qt 4.5 + FcFreeTypeQueryFace

  1. Ed says:

    That was just what I needed! I can now build and run my QT Creator “Hello World” application under Cent0s 4.2.

    Thank you very much for taking the time to document this in a detailed step-by-step style. It was just what a Linux and QT newbie like myself needed.

    Thanks again,

    -Ed

  2. Ed says:

    Correction, meant to type CentOs 5.2 not “4.2”

  3. beetle says:

    Thank you for help!

    But when i compile fontconfig 2.4.2 from source whit worng,I really desperately wanting to give it a whirl!!!

    gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../src -I/usr/local/include/freetype2 –
    Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarat
    ions -Wnested-externs -fno-strict-aliasing -DFC_CACHEDIR=\”/opt/fontconfig-2.4.2
    /var/cache/fontconfig\” -DFONTCONFIG_PATH=\”/opt/fontconfig-2.4.2/etc/fonts\” -g
    -O2 -MT fcfreetype.lo -MD -MP -MF .deps/fcfreetype.Tpo -c fcfreetype.c -fPIC –
    DPIC -o .libs/fcfreetype.o
    fcfreetype.c:69:2: warning: #warning “No FT_Get_BDF_Property: Please install fre
    etype 2.1.4 or later”
    fcfreetype.c:73:2: warning: #warning “No FT_Get_PS_Font_Info: Please install fre
    etype 2.1.1 or later”
    fcfreetype.c:126: error: ‘TT_MS_ID_UCS_4′ undeclared here (not in a function)
    fcfreetype.c:460: error: ‘TT_MS_LANGID_TIBETAN_CHINA’ undeclared here (not in a
    function)
    fcfreetype.c:460: error: initializer element is not constant
    fcfreetype.c:460: error: (near initialization for ‘fcFtLanguage[288].language_id
    ‘)
    fcfreetype.c:461: error: ‘TT_MS_LANGID_DZONGHKA_BHUTAN’ undeclared here (not in
    a function)
    fcfreetype.c:461: error: initializer element is not constant
    fcfreetype.c:461: error: (near initialization for ‘fcFtLanguage[289].language_id
    ‘)
    fcfreetype.c:508: error: ‘TT_MS_LANGID_SPANISH_UNITED_STATES’ undeclared here (n
    ot in a function)
    fcfreetype.c:508: error: initializer element is not constant
    fcfreetype.c:508: error: (near initialization for ‘fcFtLanguage[317].language_id
    ‘)
    fcfreetype.c:511: error: ‘TT_MS_LANGID_SPANISH_LATIN_AMERICA’ undeclared here (n
    ot in a function)
    fcfreetype.c:511: error: initializer element is not constant
    fcfreetype.c:511: error: (near initialization for ‘fcFtLanguage[318].language_id
    ‘)
    fcfreetype.c:512: error: ‘TT_MS_LANGID_FRENCH_NORTH_AFRICA’ undeclared here (not
    in a function)
    fcfreetype.c:512: error: initializer element is not constant
    fcfreetype.c:512: error: (near initialization for ‘fcFtLanguage[319].language_id
    ‘)
    fcfreetype.c:514: error: ‘TT_MS_LANGID_FRENCH_MOROCCO’ undeclared here (not in a
    function)
    fcfreetype.c:514: error: initializer element is not constant
    fcfreetype.c:514: error: (near initialization for ‘fcFtLanguage[320].language_id
    ‘)
    fcfreetype.c:515: error: ‘TT_MS_LANGID_FRENCH_HAITI’ undeclared here (not in a f
    unction)
    fcfreetype.c:515: error: initializer element is not constant
    fcfreetype.c:515: error: (near initialization for ‘fcFtLanguage[321].language_id
    ‘)
    fcfreetype.c:516: error: ‘TT_MS_LANGID_BENGALI_BANGLADESH’ undeclared here (not
    in a function)
    fcfreetype.c:516: error: initializer element is not constant
    fcfreetype.c:516: error: (near initialization for ‘fcFtLanguage[322].language_id
    ‘)
    fcfreetype.c:517: error: ‘TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN’ undeclared here
    (not in a function)
    fcfreetype.c:517: error: initializer element is not constant
    fcfreetype.c:517: error: (near initialization for ‘fcFtLanguage[323].language_id
    ‘)
    fcfreetype.c:518: error: ‘TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN’ undeclared
    here (not in a function)
    fcfreetype.c:518: error: initializer element is not constant
    fcfreetype.c:518: error: (near initialization for ‘fcFtLanguage[324].language_id
    ‘)
    fcfreetype.c:524: error: ‘TT_MS_LANGID_HAUSA_NIGERIA’ undeclared here (not in a
    function)
    fcfreetype.c:524: error: initializer element is not constant
    fcfreetype.c:524: error: (near initialization for ‘fcFtLanguage[325].language_id
    ‘)
    fcfreetype.c:525: error: ‘TT_MS_LANGID_YORUBA_NIGERIA’ undeclared here (not in a
    function)
    fcfreetype.c:525: error: initializer element is not constant
    fcfreetype.c:525: error: (near initialization for ‘fcFtLanguage[326].language_id
    ‘)
    fcfreetype.c:527: error: ‘TT_MS_LANGID_IGBO_NIGERIA’ undeclared here (not in a f
    unction)
    fcfreetype.c:527: error: initializer element is not constant
    fcfreetype.c:527: error: (near initialization for ‘fcFtLanguage[327].language_id
    ‘)
    fcfreetype.c:528: error: ‘TT_MS_LANGID_KANURI_NIGERIA’ undeclared here (not in a
    function)
    fcfreetype.c:528: error: initializer element is not constant
    fcfreetype.c:528: error: (near initialization for ‘fcFtLanguage[328].language_id
    ‘)
    fcfreetype.c:529: error: ‘TT_MS_LANGID_GUARANI_PARAGUAY’ undeclared here (not in
    a function)
    fcfreetype.c:529: error: initializer element is not constant
    fcfreetype.c:529: error: (near initialization for ‘fcFtLanguage[329].language_id
    ‘)
    fcfreetype.c:530: error: ‘TT_MS_LANGID_HAWAIIAN_UNITED_STATES’ undeclared here (
    not in a function)
    fcfreetype.c:530: error: initializer element is not constant
    fcfreetype.c:530: error: (near initialization for ‘fcFtLanguage[330].language_id
    ‘)
    fcfreetype.c:531: error: ‘TT_MS_LANGID_LATIN’ undeclared here (not in a function
    )
    fcfreetype.c:531: error: initializer element is not constant
    fcfreetype.c:531: error: (near initialization for ‘fcFtLanguage[331].language_id
    ‘)
    fcfreetype.c:532: error: ‘TT_MS_LANGID_SOMALI_SOMALIA’ undeclared here (not in a
    function)
    fcfreetype.c:532: error: initializer element is not constant
    fcfreetype.c:532: error: (near initialization for ‘fcFtLanguage[332].language_id ‘)
    fcfreetype.c:539: error: ‘TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES’ undeclar ed here (not in a function)
    fcfreetype.c:539: error: initializer element is not constant
    fcfreetype.c:539: error: (near initialization for ‘fcFtLanguage[333].language_id ‘)
    fcfreetype.c:1821:2: warning: #warning “No FT_Get_Next_Char: Please install free type version 2.1.0 or newer”
    fcfreetype.c: In function ‘IA__FcFreeTypeCharSetAndSpacing':
    fcfreetype.c:2656: warning: implicit declaration of function ‘FT_Get_First_Char’
    fcfreetype.c:2656: warning: nested extern declaration of ‘FT_Get_First_Char’
    fcfreetype.c: In function ‘FcFontCapabilities':
    fcfreetype.c:2955: warning: implicit declaration of function ‘FT_Load_Sfnt_Table ‘
    fcfreetype.c:2955: warning: nested extern declaration of ‘FT_Load_Sfnt_Table’
    make[3]: *** [fcfreetype.lo] Error 1
    make[3]: Leaving directory `/usr/src/fontconfig-2.4.2/src’
    make[2]: *** [all] Error 2
    make[2]: Leaving directory `/usr/src/fontconfig-2.4.2/src’
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/usr/src/fontconfig-2.4.2′
    make: *** [all] Error 2

  4. theitdepartment says:

    @Beetle: I think you’re missing the freetype-devel package. What does ‘yum install freetype-devel’ output?

  5. Alan Druce says:

    This is most succinct fix I have ever seen, and it works.
    Thanks

  6. newqtcoder says:

    Short question: When I try ./configure –prefix=/opt/fontconfig-2.4.2, hah, there is no ./configure file for me in the fontconfig-2.4.2 folder, how to solve this?

    Thank you for any hint, I also desperately want to give it a whirl! ;)

    • theitdepartment says:

      Are you sure you’re in the fontconfig src directory? (i.e. /usr/src/fontconfig-2.4.2) If you are, do an ls -la and see if there is a configure script and it it’s executable. Other than that it should be pretty straight forward.

  7. newqtcoder says:

    Sorry for the delay, I was waiting for an noticing email which apparently didn’t get through. No, there is no file called configure, I list the answer to ls -al below. There is only a text file configure.in, and somewhere inside it says: Process this file with autoconf to create configure. But when I try

    >autoconf configure.in

    then it stops with:



    configure.in:36: error: possibly undefined macro: AM_INIT_AUTOMAKE
    If this token and others are legitimate, please use m4_pattern_allow.
    See the Autoconf documentation.
    configure.in:37: error: possibly undefined macro: AM_MAINTAINER_MODE
    configure.in:58: error: possibly undefined macro: AM_CONFIG_HEADER
    configure.in:63: error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL
    configure.in:64: error: possibly undefined macro: AM_PROG_LIBTOOL
    configure.in:76: error: possibly undefined macro: AM_CONDITIONAL

    The result for ls -al is:

    [root@cache2 fontconfig-2.4.2]# ls -al
    total 172
    drwxrwxr-x 17 root root 4096 May 15 13:59 .
    drwxr-xr-x 6 root root 4096 May 13 18:59 ..
    -rw-rw-r– 1 root root 62 Dec 3 2006 AUTHORS
    -rwxrwxr-x 1 root root 2896 Dec 3 2006 autogen.sh
    drwxr-xr-x 2 root root 4096 May 15 13:59 autom4te.cache
    drwxrwxr-x 2 root root 4096 Dec 3 2006 conf.d
    drwxrwxr-x 2 root root 4096 Dec 3 2006 config
    -rw-rw-r– 1 root root 13956 Dec 3 2006 configure.in
    -rw-rw-r– 1 root root 1110 Dec 3 2006 COPYING
    drwxrwxr-x 2 root root 4096 Dec 3 2006 doc
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fc-arch
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fc-cache
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fc-case
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fc-cat
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fc-glyphname
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fc-lang
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fc-list
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fc-match
    drwxrwxr-x 2 root root 4096 Dec 3 2006 fontconfig
    -rw-rw-r– 1 root root 259 Dec 3 2006 fontconfig.pc.in
    -rw-rw-r– 1 root root 4577 Dec 3 2006 fontconfig.spec.in
    -rwxrwxr-x 1 root root 676 Dec 3 2006 fontconfig-zip.in
    -rw-rw-r– 1 root root 5173 Dec 3 2006 fonts.conf.in
    -rw-rw-r– 1 root root 6907 Dec 3 2006 fonts.dtd
    -rw-rw-r– 1 root root 1213 Dec 3 2006 .gitignore
    -rw-rw-r– 1 root root 1416 Dec 3 2006 INSTALL
    -rw-rw-r– 1 root root 756 Dec 3 2006 local.conf
    -rw-rw-r– 1 root root 4564 Dec 3 2006 Makefile.am
    -rw-rw-r– 1 root root 0 Dec 3 2006 NEWS
    -rw-rw-r– 1 root root 18347 Dec 3 2006 README
    drwxrwxr-x 2 root root 4096 Dec 3 2006 src
    drwxrwxr-x 2 root root 4096 Dec 3 2006 test
    [root@cache2 fontconfig-2.4.2]#

  8. love_juhee says:

    install fontconfig
    wget http://fontconfig.org/release/fontconfig-2.4.2.tar.gz
    tar -zxf fontconfig-2.4.2.tar.gz
    cd fontconfig-2.4.2
    ./configure –prefix=/opt/fontconfig-2.4.2
    make
    make install
    setting libconfconfig.so
    cd /usr/lib
    old library backup
    mv libfontconfig.so libfontconfig.so.b
    mv libfontconfig.so.1 libfontconfig.so.1.b
    link new library
    ln -s /opt/fontconfig-2.4.2/lib/libfontconfig.so.1.2.0 ./libfontconfig.so.1
    ln -s /opt/fontconfig-2.4.2/lib/libfontconfig.so.1.2.0 ./libfontconfig.so
    check library
    ll ./libfontconfig.so*

  9. Joseph says:

    I have created RPMs to install qt 4.5.1, fontconfig 2.5.93 and qt-creator on CentOS 5.3.

    Follow the instructions here to grab the upgrades.

  10. Aurélien says:

    Hello,

    I just came on this webpage, as I was experiencing the same problem with Debian SID distribution. But, actually, my version of fontconfig is already 2.6.0-4, so I shouldn’t have this problem, should I?

    I’ve checked, and I’ve got the /usr/lib/libfontconfig.so.1 file on my machine. Any clue?

  11. GCS says:

    Hello,

    With CentOS 5.x, QT 4.5.x and FcFreeTypeQueryFace 2.4.x, I managed to get the set up working. However, when the application is viewed via a VNC, all the fonts are really big and ugly.

    Any ieads about that?

  12. jatf says:

    Did you roll-your-own or use the RPMs from http://software.freivald.com? I use the RPMs all the time with VNC without any problems.

  13. GCS says:

    Hi jatf,

    The VNC I have tried the default VNC server that comes with CentOS as
    well as the RPM(?) from RealVNC. Both produced the same result.
    As for the fonts, I compiled it from source.
    I will try the fonts in the rpm and report back
    Thanks

  14. Arby Argueta says:

    Thank You so much. As a linux newb and after trying to find a linux solution this solution was perfect and solved my problem, Thank You so much for your help

  15. Gary S. says:

    Thanks! That was very helpful and easy to follow. I appreciate it!

  16. Carles says:

    It was not working for me, even adding the library in the linker path; I had to copy the elemts of the library
    /opt/fontconfig-2.4.2/lib at /opt/qtsdk-2010.02/qt/lib/
    I hope it may be helpful ot someone…

    • Paul Rigor says:

      Hi,

      This solution worked. I encountered this problem with Pyqt 4.7, Qt 4.7 and CentOS 5.4. I had to recompile fontconfig AND copy the libs under the qt lib folder.

      Thanks,
      Paul

    • Paul Rigor says:

      I was wondering if any of you ever encountered this issue while importing QtGui. I’ve included the traceback right below the main error message. The trace includes the version of python I’m using. Again, I’m running this under CentOS 5.4 with Qt 4.7, PyQt 4.7.2

      ==error message==
      QtCore.so: undefined symbol: PyUnicode_CompareWithASCIIString

      ==trace==
      Python 2.6.5 (r265:79063, Apr 2 2010, 19:22:01)
      [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
      Type “help”, “copyright”, “credits” or “license” for more information.
      >>> from PyQt4 import QtGui
      Traceback (most recent call last):
      File “”, line 1, in
      ImportError: /home/group/shared_libraries/centos64/pkgs/python/2.6.5/lib/python2.6/site-packages/PyQt4/QtCore.so: undefined symbol: PyUnicode_CompareWithASCIIString
      >>>

      • Paul Rigor says:

        Hi all,

        I was being careless while attempting to compile pyqt4 on multiple python versions. It works now =) That unicode method, btw, is expected by python3.

        Cheers,
        Paul

  17. Yan Bellavance says:

    This did not work for me until I removed the -L in LIBS += -L/opt/fontconfig-2.4.2/lib to get LIBS += /opt/fontconfig-2.4.2/lib.

  18. Jim says:

    THANK YOU!!!!!! For some reason the newer versions are missing the configure script. You saved me a lot of time!!! Thanks for the effort.
    Jim

  19. Ebonair says:

    I had to do quite a bit of hacking to get this working… I’m on a 64-bit system, and when I tried to build fontconfig, it told me that /usr/lib/libexpat.so was the wrong type.

    I suspected it was linking against the 32-bit libs instead of the 64-bit ones. So I followed the trail of links from /usr/lib64/libexpat.so to /lib6/libexpat.so.0.5.0.

    I copied libexpat.so.0.5.0 to /usr/lib/libexpat.so, and fontconfig compiled!

    However, adding LIBS += -L/opt/fontconfig-2.4.2/lib to the project file didn’t work either, because QtGui.so was still looking for the old version of fontconfig. I edited /etc/ld.so.conf and added /opt/fontconfig-2.4.2/lib

    Then I ran ldconfig and everything worked fine!

  20. Alex says:

    Hello,

    I did what was written here, except that I installed fontconfig in my home directory, since I don’t have rights to write to /opt . But I still get the same error.
    Is it possible to install the library in my home directory? (~/fontconfig/fontconfig-2.8.0i)
    Do I have to change anything else except for the –prefix= and the LIBS += ?

    Thanks for te nice tutorial anyway. Hope you can help me.

    Greetz,
    a

    • theitdepartment says:

      @Alex – If you compiled fontconfig with --prefix=/home/user/fontconfig/fontconfig-2.8.0i then you should only have to change the LIBS += /home/user/fontconfig/fontconfig-2.8.0i/lib in your .pro file and you should be fine. In you comment you used the ~ (tilde) shortcut – did you try the absolute path (/home/user/…)?

      Cheers,
      –The IT Department

      • Alex says:

        Yeah, I used the absolute path, otherwise the configure would complain. Here I used the ~ just for convenience.
        Strange, that’s what I did, but it doesn’t work. The “make”s seem to end without error, but I’ll check the output again to see if something went wrong.
        You didn’t use -L in LIBS += /home/user/fontconfig/fontconfig-2.8.0i/lib.
        Is it a typing error? I tried both versions anyway and neither works, just wondering. (:

  21. Joseph says:

    I’ve updated the RPM packages to Qt 4.6.3 and qtcreator 1.3.1. Here is the post:

    http://joseph.freivald.com/linux/2010/06/09/qt-4-6-3-and-qt-creator-1-3-1-1-updates-for-centos-5-5/

    To use them, use the following commands as root:

    rpm –import http://software.freivald.com/centos/RPM-GPG-KEY-software.freivald.com
    rpm -ivh http://software.freivald.com/centos/software.freivald.com-1.0.0-1.noarch.rpm
    yum update qt4 qt-creator

    • Appar Hundal says:

      After getting the RPMs and then installing/updating all specified packages, examples are working without any problem.

      Thanks you for creating the RPMs

      Appar

  22. Pingback: PyQt4 on CentOS5.5 | いろいろと

  23. toto says:

    Thank you for sharing this. I have problem when compile qt at centos5.5 and solved with this method :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: