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



Igor Zlatkovic wrote:

Good Morning,
Let me be clear, you should only link your application with -lsocket if your application needs access to a member of libsocket. Otherwise you are creating a completely unneccessary dependancy on a library that your application doesn't directly depend on.

I was wondering... Why does Sun linker create that dependence?

That's the default behaviour for the linker. See below.


The way you want to have it is the only way possible on Windows. I
cannot successfully compile a shared object without resolving all
dependences. But, my linker has a switch which makes it ignore all
libraries specified on the command line if the program being linked uses
no symbols from these libraries.

Isn't Sun's linker able to do the same, means create a dependence to
libsocket.so if and only if your program actually used something in
libsocket.so? Treat -lsocket merely as a hint for where to look for
symbols, not as an instruction to create a dependence in any case? Isn't
that possible?

It is possible, but it's not default. The default behaviour is to create dependancies for all supplied libraries. You can get the behaviour you describe by specifying the -z ignore option to the linker, which suppresses the dependency recording of unused shared objects.


Don't get me wrong, I am not taking sides here. We don't use the same
makefile, so I am neutral on the topic. I am just surprised about Sun's
compiler package.

No need to be surprised, it seems like the linker (MSVC?) you describe and the Sun linker have the same behaviour.

The reason I wanted to clean up the xml2-config script is simply because I want to help those people who aren't knowledgeable about all the options which their compilation system supports. Sure, knowledgeable people can use "-z ignore" and thus remain unaffected by the (in the case of Solaris and dynamic linking) redundant library specifications in xml2-config. However, that's not much help to the vast majority of application developers who don't know all the linker flags on all the platforms they develop on.

Gary




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