Important: Please read the Qt Code of Conduct -

[Move] Linking to ICU library

  • Hello,

    I am new to Qt and new to C++

    I am desiring to create a small application that uses a part of ICU (the ICU line-break iterator - in order to add a zero-width space between words in the Khmer language (Khmer doesn't have spaces between words). We already created a program that works in the console in Ubuntu 11.x but we are not sure how to proceed to create a GUI in Qt.

    Can anyone help give me the best option to add the ICU libraries to my project in Qt (I can compile static or shared ICU libraries)? Or direct me to documentation that would help?

    The current code and linux program can be downloaded here: if anyone wants to take a look. Or you can take a look at the sample icu/source/samples/break/break.cpp and get the general idea (the code we wrote is based on that example).


  • You can find some explanations in the "Declaring Other Libraries":/doc/qt-4.8/qmake-project-files.html#declaring-other-libraries section of the "qmake manual":/doc/qt-4.8/qmake-manual.html

    Basically you do it the same way as with other C/C++ projects.

    The short story is


    to extend the #include search path:

    INCLUDEPATH += /path/to/icu/include

    add the libs

    -L adds a search path

    only needed once for a particular path

    -l (lower case L) adds a certain lib

    needed for every lib you link against

    assuming you have a libicu.a or in that directory

    LIBS += -L/path/to/icu/lib -licu

  • Thanks Volker - that helps!

Log in to reply