views:

335

answers:

2

Whenever we specify -lxerces-c, this looks for libxerces-c.so library in the LIBPATH.

Q1. Why are lib files then generated as libxerces-c.so.28?

Q2. How should we link against such libraries?

The only way I can think of is create a soft link libxerces-c.so which links to the file libxerces-c.so.28. I feel this as an overhead to do. Is there any other way around which is better?

+1  A: 

The file name has a version number so that you can have one program that uses version 2.8 and a different program that uses version 2.9. This way, adding a new version of the library will not change the behavior of existing programs that use an old library.

Normally, there should also be a file libxerces-c.so which is a sym link to the version of the library you want your newly built programs to use.

Many Unix package managers will have a separate development package that installs the symlink. It sounds like you don't have the devel package installed.

R Samuel Klatchko
Are you saying that the libxerces-c.so symbolic link is generated automatically. http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html The article says about running ldconfig. Can you explain a bit more or point to some location
Devil Jin
That article is pretty good. One thing it states is "ldconfig doesn't set up the linker names; typically this is done during library installation, and the linker name is simply created as a symbolic link to the ``latest'' soname or the latest real name." Not sure how you ended up without the 'linker name', but for now I recommend just creating the symlink manually.
R Samuel Klatchko
A: 

There's one more reason to it: when linking to libxerces-c you also probably include some xerces header files in your program. And those headers are tied latest version of binary library (through libxerces-c.so symlink).

Meaning that if you compile with headers from xerces-2.8 and link libxerces-2.9 library binaries there's a great chance it will not work out.

Think of it as a precaution from mixing headers and binary libraries.

Aleksei Potov