scuffed-code/icu4c/source/samples/legacy
Jeff Genovy 3c7a6e30ab ICU-13171 Fix issues with ICU4C Samples, and various issues with vcxproj files.
The samples now all build on Win32, except for the layout sample (but the LE is deprecated).

X-SVN-Rev: 40951
2018-02-20 10:03:29 +00:00
..
legacy.cpp ICU-12764 UTF-8 source files, update file encoding comments. 2017-02-03 18:57:23 +00:00
legacy.sln ICU-13171 Fix issues with ICU4C Samples, and various issues with vcxproj files. 2018-02-20 10:03:29 +00:00
legacy.vcxproj ICU-13171 Update the VS project files to use VS 2017, plus various fixes to get Samples compiling. 2018-02-16 03:16:03 +00:00
legacy.vcxproj.filters ICU-11609 add svn:eol-style property to vcxproj files. 2015-04-17 21:25:48 +00:00
Makefile ICU-12761 Adds Unicode copyright notice. 2016-09-28 22:12:27 +00:00
newcol.cpp ICU-12764 UTF-8 source files, update file encoding comments. 2017-02-03 18:57:23 +00:00
oldcol.cpp ICU-12764 UTF-8 source files, update file encoding comments. 2017-02-03 18:57:23 +00:00
README ICU-12771 adds Unicode copyright statements for nine remaining files 2016-09-30 22:55:51 +00:00

Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html#License

Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved.
This example demonstrates running an instance of  ICU 1.8.1. together with a current version of ICU. It only tests u_getVersion and several collation APIs. 

Generally, one should be able to simultaneously use one or more versions of ICU 2.0 or higher and one version of ICU 1.8.1 or lower. 

What is it all about: Let's say you have a 10 Tb database indexed using ICU 1.8.1. sortkeys. New ICU comes out, with neat new features you would like to use, but also with new sortkeys and you don't care to reindex your 10 Tb database. What to do then??? You can use ICU 1.8.1. in one of your compilation units and current version in all the others. So, you can use old collation until you decide to reindex. 

You cannot mix two versions of ICU in the same compilation unit. You cannot automatically use more than one legacy version of ICU.

In order to make the compilation unit use old version of ICU, you have to do a couple of things:
1) change it's include path so that it includes header files from the old versions
2) explicitly add old libraries to the linker.
3) make sure old data can be found (if legacy code needs data).

Building and running of the example:

Linux:
To make it work, you should build and install both the current ICU and ICU 1.8.1. Put both data libraries to wherever ICU_DATA points (usually it is $(prefix)/share/icu/$(icu_version)/). If data libraries are used, then check for $(prefix)/lib/icu/1.8.1 which should contain libicudata.so and libicudt18*.so
2. Copy libicuuc.so.18* and libicui18n.so.18* to $(prefix)/lib directory, together with current libraries). 
3. Should work on other Unixes.


Change $ICU_PREFIX to point to the current installation, and $ICU_LEGACY to point to 1.8.1 installation. $ICU_LEGACY is needed solely to access the 1.8.1 include directory through $LEGACY_INCLUDE variable, so if you want to move the 1.8.1. include directory, you can set $LEGACY_INCLUDE directly to that directory.

Run make check. You should get two different libraries running at the same time.

Win32:
Build both current ICU and ICU 1.8.1. Take icuuc18.dll, icuin18.dll and icudt18l.dll and put them somewhere in PATH (a sane place would be wherever current dlls go). 

Edit the include directory for oldcol.cpp so that it points to the include directory of ICU 1.8.1.
Edit the two library entries with path so that they point to .lib files for your version of ICU.

Hit F7, followed by ctrl-F5.

Troubleshooting (all platforms):
Sample won't compile: this is quite unlikely, but the most probable reason is that include files cannot be found. 
Sample won't link: The path for 1.8.1. libraries is broken. Edit it so that it  reflects the path to your libraries.
Linker says: "Undefined symbol u_getVersion()" (or something similar): path to 1.8.1. libraries is bad.
Linker says: "Undefined symbol u_getVersion()_X_Y" (or something similar): path to current libraries is bad.
Legacy crashes horribly: Sorry, didn't put any error checking. If legacy crashes that's most probably because it cannot find the data libraries. You can see which data library is not found by the part of the program that is running. Make sure program can find tha data library either by putting it where ever ICU_DATA points to OR by putting the DLL version of the data library somewhere on your PATH.