Re: [xml] Generating a correct xml2-config for use with --libs

Daniel Veillard wrote:

On Thu, Jun 13, 2002 at 12:02:17PM +0100, Gary Pennington wrote:

Patches which removes the unnecessary declaration of dependencies on libraries which libxml2 depends upon itself, when generating the xml2-config script.


Applications should only depend on those libraries which they need to link to.


xml2-config lists all the libraries which libxml2 itself depends on, when xml2-config is invoked:


$ xml2-config --libs
-L/usr/local/libxml/sparc/lib -R/usr/local/libxml/sparc/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl

This is wrong, the following is correct:

$ xml2-config --libs
-L/usr/local/libxml/sparc/lib -R/usr/local/libxml/sparc/lib -lxml2

 Hum, I don't see why !

If libxml2 requires -lsocket, then I want it on the linker command line.

I want $(CC) `xml2-config --cflags` foo.c -o foo `xml2-config --libs`

to be a working command to compile and link foo.c if it depends on libxml2
and this independantly of the (unix-like) system it's ran on. I don't really
care about extra dependancies, but I really want it to work everywhere.

Maybe Solaris doesn't need this, but then please make the patch conditional
to Solaris first (unless I misunderstood something).

I didn't think this was Solaris specific...

An application need only link against libraries it explicitly uses. If foo uses networking code, then it should link with the appropriate networking libraries. If however, foo's only "use" of networking is performed by libxml2, then it is libxml2 which needs to link with the networking libraries and not foo.

So, the patch I provided removes unneccessary dependencies on libraries that applications, such as foo, don't need.

If you are saying that Linux (I presume you are talking about Linux) requires all libraries to be specified (even libraries that a dependant of a dependant of a dependant, etc...) to the linker, then I am really surprised. That is the case with static libraries (and ordering is important); but not with shared objects. That's the job of the linker.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]