Re: [xml] Mac OS-X: Why are binaries linked against libxml2.dylib?

Nathanael Noblet wrote:

On Jun 3, 2005, at 10:54 AM, Rush Manbert wrote:

Nathanael Noblet wrote:

On Jun 3, 2005, at 10:39 AM, Rush Manbert wrote:

Well, I could if I wanted to write my own makefile. All this stuff is set up by ./configure, but there doesn't appear to be a --with-static-binaries (or equivalent) flag. One of my goals is to use the package as distributed to build and install, then do what I need to do to make it usable in my situation. I don't want to maintain my own xmllint project, for example. (I know it's pretty simple in this case, but I have an identical problem with xsltproc, which has more complicated dependencies...)

You don't need to create your own makefiles. Set the flags before you call configure or make so for example:
LD_FLAGS=..... CFLAGS=... ./configure
and then
LD_FLAGS=.... CFLAGS=... make

Oh, sorry. Yes, that's true if it were a command line flag. However, the link line looks like this: gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o .libs/xmllint xmllint.o ./.libs/libxml2.dylib -lpthread -lm

and I need it to look like this:
gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o .libs/xmllint xmllint.o ./.libs/libxml2.a -lpthread -lm

I don't know of a way to change this with the environment variables.

I'm no expert in this area, that is for sure, but I'm pretty sure you can tell it during the configure stage what to do, using either configure flags or environment variables to use the static compilation, which would propagate to the makefile and change that for you. The exact method to do this, well I don't know it. I've seen places where I used configure and environment variables to affect these things. For example when compiling your program, after you've compiled libxml2.a you could do
LD_FLAGS=-L./path/to/parent/of./.libs/libxml2.a ./configure
or use ./configure --with-libxml2-dir=/path....


The -L would work if the library were specified as -lxml2, because the loader would expand that and do a search. Even this seems to be a problem on the Mac. When you say -lxml2 on a link line, they seem to search the library paths for libxml2.*, because when you have libxml2.dylib and libxml2.a in the same directory, they choose to link against libxml2.dylib. My guess is that this is because you can't statically link against the OS libraries on the Mac, ( ) they only allow dynamic linking. This is moot, though, because the library is explicitly named as ./.libs/libxml2.dylib and there's no search for that.

What you say about the configuration is what I'm looking for. If you run ./configure --help, nothing sounds like it changes this behavior. I'm hoping that someone (Daniel probably) will know of a configuration option that might be missed in the help output. I could start tearing apart the configure script, but I'm not an expert in those. If there is such an option, it probably applies to any Unix platform, so anyone out there who's listening could chime in...

- Rush

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