views:

92

answers:

2

I'm a relative noob to installing libraries. My system currently has an older version of the ICU library (3.8) and I want to go the latest (4.4).

Following the steps in the ICU readme.html, everything goes fine (echo $? produces all 0 for every step). And I see the libary was installed to /usr/local/lib. However the current version of the library is is installed in /usr/lib.

My questions.

1) Is there an "organzational" or some other significant difference between these two locations?

2) How can I change the install path for the new library to /usr/lib?

3) Is the library being in the wrong location the reason why when I run even the samples in the ICU directory, I get "error while loading shared libraries: libicui18n.so.44"?

Thanks all.

+2  A: 

1) Stuff directly in /usr belongs to your distribution and should not be modified except via its package manager. Stuff in /usr/local belongs to the local installation, and is for you to manage as you see fit. Thus, it is correct to put a local installation of a newer libICU in /usr/local/lib.

2) You can do this by adjusting some settings when you build ICU - I can't give you specific advice because I don't know what build harness ICU uses. However, you should not do this, because that will overwrite the distribution's files, which can cause arbitrarily horrible breakage.

3) Sort of. The problem is not that the library was installed in the wrong place, but that /usr/local/lib isn't in the default search path. You can fix this two ways:

  • temporarily for yourself with this shell command:

    export LD_LIBRARY_PATH=/usr/local/lib
    
  • permanently for all users, by adding /usr/local/lib to the list in /etc/ld.so.conf and then running ldconfig as root.

Zack
3) the adjusted LD_LIBRARY_PATH will still not make it visible for e.g. autoconf. For that add the path to the LDFLAGS: ./configure LDFLAGS=-L/usr/local/lib.
honk
honk: good point, I forgot that bit.
Zack
Adding the LD_LIBRARY_PATH got the samples to run properly, thank you. However when I try to compile my program (which was working on the previous version of ICU), I get errors like this during linking. undefined reference to `icu_44::Calendar::getNow()
Travis
Please post the output of `nm -o --dynamic /usr/local/lib/libicu*.so | grep getNow`.
Zack
# nm -o --dynamic /usr/local/lib/libicu*.so | grep getNow/usr/local/lib/libicui18n.so:000c48a0 T _ZN6icu_448Calendar6getNowEv/usr/local/lib/libicui18n.so:000c0940 T ucal_getNow_44/usr/local/lib/libicutu.so: U ucal_getNow_44
Travis
`T _ZN6icu_448Calendar6getNowEv` means that `icu_44::Calendar::getNow()` is indeed exported by your new library. Did you have `-licui18n` on your link line?
Zack
Yeah it is. But what takes -licui18n and maps it to the location of the library? The version of the library that came with my distro is still in /usr/lib so could -licui18n be pointing to that instead of the 4.4. version I installed into /usr/local/lib?
Travis
Quite possible. Try adding `-L/usr/local/lib` to the link line (before the `-licui18n`). That's what honk was talking about way above.
Zack
A: 
  1. /usr/local is the directory hierarchy for locally installed software. /usr/bin, /usr/lib/, etc. are for system managed files (i.e. the ones managed by your distributions tools like rpm yum dselect etc.)
  2. You shouldn't install things into /usr/lib generally
  3. You may need to run ldconfig (as root) to update the library cache that maps names (like libicui18n.so.44) to path names (like /usr/local/lib/libicui18n.so.44)

Another wrinkle is that if you have an x86_64 system, the correct library path for 64 bit libraries is /usr/local/lib64 not /usr/local/lib. In this case add --libdir=/usr/local/lib64 to the ./configure command line when building ICU.

Geoff Reedy