GNOME Bugzilla – Bug 630910
glib: build is broken when zlib is not on a standard location
Last modified: 2011-09-09 00:14:37 UTC
Created attachment 171341 [details] [review] Proposed fix. This is the error: gzlibcompressor.c:26: fatal error: zlib.h: No such file or directory This comes from bug #623473; my original patch worked, but apparently somebody doesn't appreciate lines of code that are actually tested and thinks they can be discarded without any comment and claiming the patch is now theirs... Never-mind the brokenness. Hopefully this patch is as minimal as it gets, and it can't be miss-represented as unnecessary, or whatever.
Isn't that what CPPFLAGS and LDFLAGS are for?
(In reply to comment #1) > Isn't that what CPPFLAGS and LDFLAGS are for? Nope, CPPFLAGS can be overridden by the user... An alternative would be to do: libgio_2_0_la_CPPFLAGS = $(ZLIB_CFLAGS) $(AM_CPPFLAGS) I'm testing that now.
That's what I mean, that the "user" (the person building glib) can pass CPPFLAGS and LDFLAGS as necessary for it to find zlib headers and libraries.
Created attachment 171348 [details] [review] Alternative proposed fix Just to avoid other "rewrites".
(In reply to comment #3) > That's what I mean, that the "user" (the person building glib) can pass > CPPFLAGS and LDFLAGS as necessary for it to find zlib headers and libraries. No, that's the whole point of pkg-config: http://en.wikipedia.org/wiki/Pkg-config This should work (even if libz is installed in /opt/libz): gcc -o test test.c $(pkg-config --libs --cflags libz)
I know fully well what the point of pkg-config is. But do the zlib maintainers? (OK, so in version 1.2.5 they apparently do. So should we require version 1.2.5?)
(In reply to comment #6) > I know fully well what the point of pkg-config is. But do the zlib maintainers? > (OK, so in version 1.2.5 they apparently do. So should we require version > 1.2.5?) That is irrelevant; the code to use pkg-config is already there, but broken. And even if it wasn't, and you use an old zlib: * You can define ZLIB_CFLAGS and ZLIB_LIBS * You can write your own .pc file * You can rely on your distribution adding the .pc file (like Fedora does, although it's anyway in /usr) * Or even as you say, use CPPFLAGS and LDFLAGS The point is that adding the pkg-config stuff only helps.
Created attachment 173962 [details] [review] gio.pc.in: depend on zlib And 'pkg-config --libs gio' is not returning the right flags.
(In reply to comment #8) > Created an attachment (id=173962) [details] [review] > gio.pc.in: depend on zlib > > And 'pkg-config --libs gio' is not returning the right flags. IMO this patch is wrong, since it a) always adds the zlib dep to the pc file, even if gio isn't compiled with zlib support, and b) if the zlib dep should be put in the pc file at all (which I take no position on here), it should be in Requires.private, not Requires.
(In reply to comment #9) > (In reply to comment #8) > > Created an attachment (id=173962) [details] [review] [details] [review] > > gio.pc.in: depend on zlib > > > > And 'pkg-config --libs gio' is not returning the right flags. > > IMO this patch is wrong, since it a) always adds the zlib dep to the pc file, > even if gio isn't compiled with zlib support gio is always compiled with zlib support. > and b) if the zlib dep should be > put in the pc file at all (which I take no position on here), it should be in > Requires.private, not Requires. That's what I thought, but the linker is failing to detect the dependency automatically, I don't know why.
Hellooo?
(In reply to comment #11) > Hellooo? What operating system and version is this, and how are you configuring the build?
(In reply to comment #12) > (In reply to comment #11) > > Hellooo? > > What operating system and version is this, and how are you configuring the > build? Have you even looked at the patches? They are obvious fixes. 1) remove zlib-devel 2) install zlib to /opt/zlib 3) export PKG_CONFIG_PATH=/opt/zlib/lib/pkgconfig See for yourself.
(In reply to comment #13) > (In reply to comment #12) > > (In reply to comment #11) > > > Hellooo? > > > > What operating system and version is this, and how are you configuring the > > build? > > Have you even looked at the patches? They are obvious fixes. I agree with Christian that adding zlib to Requires is definitely wrong; it would be Requires.private if anything. If you added it to Requires, it would force every process linking to gio to also link to zlib, which is clearly wrong, since it's an implementation detail, not part of the API.
(In reply to comment #14) > I agree with Christian that adding zlib to Requires is definitely wrong; it > would be Requires.private if anything. > > If you added it to Requires, it would force every process linking to gio to > also link to zlib, which is clearly wrong, since it's an implementation detail, > not part of the API. Suppose zlib is installed in /opt/zlib, and glib in /opt/glib, how do you propose to make this work? arm-linux-gcc $(pkg-config --cflags --libs gio-2.0) test.c -o test /opt/arm-2009q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: warning: libz.so.1, needed by /opt/tmp/glib/lib/libgio-2.0.so, not found (try using -rpath or -rpath-link) /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `inflateReset' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `inflateEnd' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `deflate' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `deflateInit_' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `inflateInit2_' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `deflateSetHeader@ZLIB_1.2.2' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `inflate' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `deflateEnd' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `deflateReset' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `inflateGetHeader@ZLIB_1.2.2' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `inflateInit_' /opt/tmp/glib/lib/libgio-2.0.so: undefined reference to `deflateInit2_' collect2: ld returned 1 exit status Clearly, the linker has no way of finding libz.so.1. It looks like -rpath-link should do the trick, but it doesn't here. Anyway, that's a separate issue, attachment #171348 [details] is the important one.
(In reply to comment #15) > > arm-linux-gcc $(pkg-config --cflags --libs gio-2.0) test.c -o test What does $(pkg-config --cflags --libs gio-2.0) output if zlib was in Requires.private? And what version of pkg-config?
(In reply to comment #16) > (In reply to comment #15) > > > > arm-linux-gcc $(pkg-config --cflags --libs gio-2.0) test.c -o test > > What does $(pkg-config --cflags --libs gio-2.0) output if zlib was in > Requires.private? And what version of pkg-config? % pkg-config --cflags --libs gio-2.0 -pthread -I/opt/tmp/glib/include/glib-2.0 -I/opt/tmp/glib/lib/glib-2.0/include -pthread -L/opt/tmp/glib/lib -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 This is linux; Requires.private is ignored for shared libraries. % pkg-config --version 0.25
(In reply to comment #17) > (In reply to comment #16) > > (In reply to comment #15) > > > > > > arm-linux-gcc $(pkg-config --cflags --libs gio-2.0) test.c -o test > > > > What does $(pkg-config --cflags --libs gio-2.0) output if zlib was in > > Requires.private? And what version of pkg-config? > > % pkg-config --cflags --libs gio-2.0 > -pthread -I/opt/tmp/glib/include/glib-2.0 -I/opt/tmp/glib/lib/glib-2.0/include > -pthread -L/opt/tmp/glib/lib -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 > -lgthread-2.0 -lrt -lglib-2.0 > > This is linux; Requires.private is ignored for shared libraries. Well, it's still useful for dependency generator implementations (think rpm, etc.). However, one thing I don't understand in this situation is why pkg-config doesn't add -L /opt/zlib/lib.
(In reply to comment #18) > (In reply to comment #17) > > This is linux; Requires.private is ignored for shared libraries. > > Well, it's still useful for dependency generator implementations (think rpm, > etc.). And static libraries. > However, one thing I don't understand in this situation is why pkg-config > doesn't add -L /opt/zlib/lib. Because it's in the private libs, but that only matters when linking the libraries, not the dependencies.
Ok, I've removed the patch for the .pc file since apparently pkg-config is at fault. Now, can we get the obviously good fix in?
Hellooooo? What's wrong with attachment #171348 [details]?
Comment on attachment 171348 [details] [review] Alternative proposed fix Looks fine to me.