CompilerFor ICU4C 50 or newer theconfigure script picks clang if it is installed, or else gcc . Clang produces superior error messages and warnings.Most Linuxes should have clang available to install. On Ubuntu or other Debian-based systems, install it with sudo apt-get install clang Debug builds must use compiler option Release builds can use
Other build flagsOn a modern Linux you can configure with Debugging
Portability TestingGitHub pull requests are automatically tested on Windows, Linux with both clang & gcc, and Macintosh. The build results show up as check results on the status page. Build errors will block the pull request. It's also useful to check the build logs for new warnings on platforms other than the one used for development. Clang sanitizersClang has built-in santizers to check for several classes of problems. Here are the configure options for building ICU with the address checker: CPPFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address ./runConfigureICU --enable-debug --disable-release Linux --disable-renaming
thread , memory and undefined behavior. At the time of this writing, thread and address run cleanly, the others show warnings that have not yet been resolved.Heap Usage (ICU4C)HeapTrack is a useful tool for analyzing heap usage of a test program, to check the total heap activity of a particular function or object creation, for example. It will show totals by line in the source, and can move up and down the stack to see more detail.To install on Linux,
Quick Scripts for small test programsI use the following simple scripts to simplify building and debugging small stand-alone programs against ICU, without needing to set up makefiles. They assume a program with a single .cpp file with the same name as the directory in which it resides. b: build r: run d: debug v: run under valgrind You will probably need to modify them to reflect where you keep your most commonly used ICU build, and whether you routinely use an out-of-source ICU build. $ cat `which b` #! /bin/sh if [[ -z "${ICU_HOME}" ]] ; then ICU_HOME=$HOME/icu/icu4c fi DIR=`pwd` PROG=`basename $DIR` clang++ -g -I $ICU_HOME/source/common -I $ICU_HOME/source/i18n -I $ICU_HOME/source/io -L$ICU_HOME/source/lib -L$ICU_HOME/source/stubdata -licuuc -licui18n -licudata -o $PROG $PROG.cpp $ cat `which r` #! /bin/sh cat `which d` $ cat `which v` #! /bin/sh |
Source Code Access > Tips (for developers) >