How to add ICU library to project?

icu library c++
install icu windows
libicu
icu tutorial
icu project
icu cmake
icu4j
libicu latest version

Help me please. I would like to add ICU library to my project. My cmake version is 2.8.12.2.

There is CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

project(test1)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) set(CMAKE_CXX_COMPILER /usr/bin/g++) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -Wall")

find_package(Boost 1.54.0 COMPONENTS filesystem system regex unit_test_framework REQUIRED) find_package(ICU 52.0 REQUIRED )

include_directories(${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARY_DIR})

add_executable(test1 src/dictionary.cpp src/main.cpp ) target_link_libraries( test1 ${Boost_LIBRARIES} pthread )

I have installed ICU libraries: libicu-dev, libicu-dev:i386, libicu52, libicu52:i386, libicu52-dbg:i386

But once I run CMake, I get the following error message:

CMake Error at CMakeLists.txt:10 (find_package):
  By not providing "FindICU.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "ICU", but
  CMake did not find one.

  Could not find a package configuration file provided by "ICU" (requested
  version 52.1) with any of the following names:

    ICUConfig.cmake
    icu-config.cmake

  Add the installation prefix of "ICU" to CMAKE_PREFIX_PATH or set "ICU_DIR"
  to a directory containing one of the above files.  If "ICU" provides a
  separate development package or SDK, be sure it has been installed.

What should I do? Help me please.

This problem was solved by adding the file FindICU.cmake at top of the project directory from http://github.com/julp/FindICU.cmake

ICU FAQs, see "Customizing ICU's Data Library" (�) in http://www.icu-project.org/charts/ charset/ or� ICU installs the pkg-config (.pc) files in $ (prefix)/lib/pkgconfig (where $ (prefix) is the installation prefix for ICU). It may be necessary to add $ (prefix)/lib/pkgconfig to the PKG_CONFIG_PATH variable. If you use ICU in a small project, it may be convenient to take advantage of ICU's autoconf'ed files.

Using CMake 3.13.

add_executable(myapp
    main.cpp
)

# ICU Components Reference:
# https://cmake.org/cmake/help/latest/module/FindICU.html
# ICU components = data, i18n, io, le, lx, test, tu and uc.

find_package(ICU 61.0 COMPONENTS uc i18n REQUIRED)

# Link using the imported target names (ICU::uc, ICU::i18n, etc.)

target_link_libraries(myapp ICU::uc ICU::i18n)

Note: This wouldn't work unless I specifically listed the components in the find_package statement.

How To Use ICU, ICU builds and installs as relatively standard libraries. is to use the pkg-config files which are installed by ICU upon " make install ". If you use ICU in a small project, it may be convenient to take advantage of ICU's autoconf 'ed files. If all you need are the development libraries, try installing libicu-dev and if you need the actual library, the name is libicu48. apt-cache search libicu This did the trick. So: sudo apt-get install libicu-dev

If ICU library is required, use:

find_package(ICU REQUIRED components...)
target_link_libraries(lab1 ${ICU_LIBRARIES})

If it's optional, use:

find_package(ICU COMPONENTS components...)
target_link_libraries(lab1 ${ICU_LIBRARIES})

Where components... is a list of ICU library components that can be found here. INSERT these lines ONLY AFTER add_executable command!

International Components for Unicode (ICU), International Components for Unicode (ICU) is a mature, widely used set page here: http://icu-project.org/apiref/icu4c/index.html#Module The ICU library was first added to the Windows 10 OS in this version. On Windows 10 Version 1709 and above, you should include the combined header instead:. 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 libicu.so in that directory. LIBS += -L/path/to/icu/lib -licu @

It is all about including the headers and linking the libraries. For small projects, you can probably just do, (assume you already have ICU properly installed, and can be run manually)

include_directories(${ICU_INCLUDE_DIRS})
link_directories(${ICU_LIBRARY_DIRS})
add_executable(test1 src/dictionary.cpp src/main.cpp ) 
target_link_libraries(test1 ${ICU_LIBRARIES})

You can use below to print the info when you run "cmake" to check if cmake finds the correct path.

MESSAGE("ICU_INCLUDE_DIRS: " ${ICU_INCLUDE_DIRS})

The cmake version I am using is 3.5.2

ICU-67.1, The International Components for Unicode (ICU) package is a mature, widely used set of C/C++ libraries providing Unicode and Globalization Estimated build time: 0.9 SBU (Using parallelism=4; add 1.9 SBU for tests)� The ICU project provides a large number of additional locales in its locale repository on the web. Most of this locale data is derived from the CLDR (Common Locale Data Repository) project. As of ICU 64, dropping the txt file into the correct place in the source tree is sufficient to add it to your ICU build.

Eclipse Setup for ICU4J Users - ICU, ICU Project Site. This instruction assumes that you create a new workspace for ICU4J. JavaDoc classes are not a part of Java runtime library (rt.jar). ICU is widely portable and gives applications the same results on all platforms and between C/C++ and Java software. ICU is released under a nonrestrictive open source license that is suitable for use with both commercial software and with other open source or free software. Here are a few highlights of the services provided by ICU:

unicode-org/icu: The new home of the ICU project source , The new home of the ICU project source code. Contribute to unicode-org/icu development by creating an account on GitHub. The new home of the ICU project source code. Contribute to unicode-org/icu development by creating an account on GitHub.

Building and Installing the Library - 1.61.0, If you don't want the regex library to use ICU then build with the "--disable-icu" will add "some-include-path" to your compilers header include path, or if ICU� Latest Release. ICU 67 is now available. For details about new features and other improvements, see Download ICU 67.. Official Releases. If you want to use ICU (as opposed to developing it), it is recommended that you download an official packaged version of the ICU source code.

Comments
  • Since version 3.7.0, CMake comes with a packaged FindICU.cmake, which however works differently to the one by julp (i.e. is incompatible).
  • @DevSolar, on my macbook with homebrew installed icu4c, it's not working.
  • @linrongbin This comment is hardly the place to debug the issue; perhaps ask a separate question?
  • "Note: This wouldn't work unless I specifically listed the components in the find_package statement." You, sir, are a life-saver!