Compiling an ICU application

If you're writing a C application using ICU, there are two way in which you can compile it: statically or dynamically linked.

Static linking

If you want to compile your application statically, then you first need to compile the ICU libraries statically.

./configure --enable-static --prefix=/usr && make && sudo make install

After the ICU libraries have been compiled statically, you can compile your application as follows, using the C++ compiler, because it needs to include the standard C++ libraries.

g++ main.c -o main.o -static -lsicuio -lsicui18n -lsicuuc -lsicudata

Dynamic linking

Linking your application dynamically is easier, since you can use the icu-config tool to generate gcc parameters and you also don't need to use the C++ compiler, since the C++ libraries should be available in the system.

gcc main.c -o main.o `icu-config --ld-flags --ld-flags-icuio`