Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 86988
Status: resolved
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 804.031
Fixed in: 804.031_500

Attachments


Subject: Test for system libpng is missing -lz
804.031 cannot detect system libpng because the test forget to link against zlib: system('pkg-config --exists libpng'); if ($? == 0) { chomp($libpng_cflags = `pkg-config --cflags libpng`); chomp($libpng_libs = `pkg-config --libs libpng`); } else { warn "'pkg-config libpng' failed, continue with fallback values for cflags and libs...\n"; $libpng_cflags = '-I/usr/local/include'; $libpng_libs = '-lpng -lz -lm'; } if ($Tk::MMtry::VERSION ge '4.007' && try_run("config/has_png.c",[$libpng_cflags],[$libpng_libs])) And config/has_png.c calls zlibVersion(). My libpng does not output zlib as build-time dependency: # pkg-config --libs libpng -lpng16 I propose to add '-lz' to the $libpng_libs.
From: ppisar [...] redhat.com
Dne St 17.čec.2013 04:41:28, ppisar napsal(a): Show quoted text
> 804.031 cannot detect system libpng because the test forget to link > against zlib:
Attached patch implements it.
Subject: Tk-804.031-Link-PNG-test-to-zlib.patch
From b486af844498013073000808890fb19917f00823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Wed, 17 Jul 2013 10:43:28 +0200 Subject: [PATCH] Link PNG test to zlib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit <https://rt.cpan.org/Public/Bug/Display.html?id=86988>. Signed-off-by: Petr Písař <ppisar@redhat.com> --- PNG/Makefile.PL | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PNG/Makefile.PL b/PNG/Makefile.PL index dfb40d4..fe6c222 100755 --- a/PNG/Makefile.PL +++ b/PNG/Makefile.PL @@ -25,8 +25,9 @@ if ($? == 0) { } else { warn "'pkg-config libpng' failed, continue with fallback values for cflags and libs...\n"; $libpng_cflags = '-I/usr/local/include'; - $libpng_libs = '-lpng -lz -lm'; + $libpng_libs = '-lpng -lm'; } +$libpng_libs .= ' -lz'; if ($Tk::MMtry::VERSION ge '4.007' && try_run("config/has_png.c",[$libpng_cflags],[$libpng_libs])) -- 1.8.1.4
On 2013-07-17 04:41:28, ppisar wrote: Show quoted text
> 804.031 cannot detect system libpng because the test forget to link > against zlib: > > system('pkg-config --exists libpng'); > if ($? == 0) { > chomp($libpng_cflags = `pkg-config --cflags libpng`); > chomp($libpng_libs = `pkg-config --libs libpng`); > } else { > warn "'pkg-config libpng' failed, continue with fallback values > for cflags and libs...\n"; > $libpng_cflags = '-I/usr/local/include'; > $libpng_libs = '-lpng -lz -lm'; > } > > if ($Tk::MMtry::VERSION ge '4.007' && > try_run("config/has_png.c",[$libpng_cflags],[$libpng_libs])) > > And config/has_png.c calls zlibVersion(). > > My libpng does not output zlib as build-time dependency: > > # pkg-config --libs libpng > -lpng16 > > I propose to add '-lz' to the $libpng_libs.
Which system is this? On my debian system, -lz is not listed in the pkg-config output, but things are working nevertheless. On my freebsd system, the output of pkg-config includes -lz: $ pkg-config --libs libpng -L/usr/local/lib -lpng -lz -lm So it seems to me that the output of pkg-config should include -lz if it's needed? Regards, Slaven
Subject: Re: [rt.cpan.org #86988] Test for system libpng is missing -lz
Date: Wed, 17 Jul 2013 16:19:37 +0200
To: Slaven_Rezic via RT <bug-Tk [...] rt.cpan.org>
From: Petr Pisar <ppisar [...] redhat.com>
On Wed, Jul 17, 2013 at 09:56:10AM -0400, Slaven_Rezic via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=86988 > > > On 2013-07-17 04:41:28, ppisar wrote:
> > 804.031 cannot detect system libpng because the test forget to link > > against zlib: > > > > system('pkg-config --exists libpng'); > > if ($? == 0) { > > chomp($libpng_cflags = `pkg-config --cflags libpng`); > > chomp($libpng_libs = `pkg-config --libs libpng`); > > } else { > > warn "'pkg-config libpng' failed, continue with fallback values > > for cflags and libs...\n"; > > $libpng_cflags = '-I/usr/local/include'; > > $libpng_libs = '-lpng -lz -lm'; > > } > > > > if ($Tk::MMtry::VERSION ge '4.007' && > > try_run("config/has_png.c",[$libpng_cflags],[$libpng_libs])) > > > > And config/has_png.c calls zlibVersion(). > > > > My libpng does not output zlib as build-time dependency: > > > > # pkg-config --libs libpng > > -lpng16 > > > > I propose to add '-lz' to the $libpng_libs.
> > Which system is this?
Fedora 18 and 20. Show quoted text
> On my debian system, -lz is not listed in the pkg-config output,
That's correct. Show quoted text
> but things are working nevertheless.
Probably because of opportunistic linker in your distribution. libpng links itself to libz what can make libz symbols available to the test program. However this is not portable. If libpng stopped using zlib, then your test program would miss symbols from libz. If the test program includes zlib headers and calls functions from lzib, then it must be linked to libz explictly. Otherwise strict linker will complain about unresolved zlibVersion symbol. Show quoted text
> On my freebsd system, the output of pkg-config includes -lz: > > $ pkg-config --libs libpng -L/usr/local/lib -lpng -lz -lm >
Because some linkers require repeating libraries that are needed by already linked libraries. Sometimes it's just a dummy fall-back for case when a library is static but it has dynamic dependenies. Show quoted text
> So it seems to me that the output of pkg-config should include -lz if it's > needed? >
Unless libpng uses zlib data structures to pass data between application and libpng, hence including zlib headers through libpng headers (i.e. #include <png.h> is enough to use definitions from <zlib.h> without including <zlib.h> explicitly), there is no need to link each libpng aplication to libz, thus pkg-config should not output -lz. -- Petr
Download (untitled)
application/pgp-signature 230b

Message body not shown because it is not plain text.

On 2013-07-17 10:19:57, ppisar wrote: Show quoted text
> On Wed, Jul 17, 2013 at 09:56:10AM -0400, Slaven_Rezic via RT wrote:
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=86988 > > > > > On 2013-07-17 04:41:28, ppisar wrote:
> > > 804.031 cannot detect system libpng because the test forget to
> link
> > > against zlib: > > > > > > system('pkg-config --exists libpng'); > > > if ($? == 0) { > > > chomp($libpng_cflags = `pkg-config --cflags libpng`); > > > chomp($libpng_libs = `pkg-config --libs libpng`); > > > } else { > > > warn "'pkg-config libpng' failed, continue with fallback
> values
> > > for cflags and libs...\n"; > > > $libpng_cflags = '-I/usr/local/include'; > > > $libpng_libs = '-lpng -lz -lm'; > > > } > > > > > > if ($Tk::MMtry::VERSION ge '4.007' && > > > try_run("config/has_png.c",[$libpng_cflags],[$libpng_libs])) > > > > > > And config/has_png.c calls zlibVersion(). > > > > > > My libpng does not output zlib as build-time dependency: > > > > > > # pkg-config --libs libpng > > > -lpng16 > > > > > > I propose to add '-lz' to the $libpng_libs.
> > > > Which system is this?
> Fedora 18 and 20. >
> > On my debian system, -lz is not listed in the pkg-config output,
> > That's correct. >
> > but things are working nevertheless.
> > Probably because of opportunistic linker in your distribution. libpng > links > itself to libz what can make libz symbols available to the test > program. > However this is not portable. If libpng stopped using zlib, then your > test > program would miss symbols from libz. > > If the test program includes zlib headers and calls functions from > lzib, then > it must be linked to libz explictly. Otherwise strict linker will > complain > about unresolved zlibVersion symbol.
So the correct approach would probably be to include also the output of pkg-config --cflags zlib pkg-config --libs zlib for linking the test program here (rather than hardcoding "-lz")? Regards, Slaven
Subject: Re: [rt.cpan.org #86988] Test for system libpng is missing -lz
Date: Thu, 18 Jul 2013 07:22:45 +0200
To: Slaven_Rezic via RT <bug-Tk [...] rt.cpan.org>
From: Petr Pisar <ppisar [...] redhat.com>
On Wed, Jul 17, 2013 at 10:27:46AM -0400, Slaven_Rezic via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=86988 > > > So the correct approach would probably be to include also the output of > > pkg-config --cflags zlib > pkg-config --libs zlib > > for linking the test program here (rather than hardcoding "-lz")? >
Yes. Assuming zlib provides pkg-config file. I thought it doesn't, but I did a typo probably. I rechecked it now and pkg-config knows zlib on my system. So this is the right way. -- Petr
Download (untitled)
application/pgp-signature 230b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #86988] Test for system libpng is missing -lz
Date: Thu, 18 Jul 2013 09:50:21 -0400
To: bug-Tk [...] rt.cpan.org
From: "Daniel Macks" <dmacks [...] netspace.org>
On OS X 10.8, I don't see a zlib.pc (either by searching the filesystem or by using fink's `pkg-config`) but I do have libz.dylib and zlib.h version 1.2.5. A .pc isn't supplied until version 1.2.7 (according to http://www.zlib.net/ChangeLog.txt) dan -- Daniel Macks dmacks@netspace.org
Subject: Re: [rt.cpan.org #86988] Test for system libpng is missing -lz
Date: Thu, 18 Jul 2013 15:55:16 +0200
To: "dmacks [...] netspace.org via RT" <bug-Tk [...] rt.cpan.org>
From: Petr Pisar <ppisar [...] redhat.com>
On Thu, Jul 18, 2013 at 09:50:44AM -0400, dmacks@netspace.org via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=86988 > > > On OS X 10.8, I don't see a zlib.pc (either by searching the filesystem or > by using fink's `pkg-config`) but I do have libz.dylib and zlib.h version > 1.2.5. A .pc isn't supplied until version 1.2.7 (according to > http://www.zlib.net/ChangeLog.txt) >
That's possible. I have 1.2.7. -- Petr
Download (untitled)
application/pgp-signature 230b

Message body not shown because it is not plain text.

On 2013-07-17 04:41:28, ppisar wrote: Show quoted text
> 804.031 cannot detect system libpng because the test forget to link > against zlib: > > system('pkg-config --exists libpng'); > if ($? == 0) { > chomp($libpng_cflags = `pkg-config --cflags libpng`); > chomp($libpng_libs = `pkg-config --libs libpng`); > } else { > warn "'pkg-config libpng' failed, continue with fallback values > for cflags and libs...\n"; > $libpng_cflags = '-I/usr/local/include'; > $libpng_libs = '-lpng -lz -lm'; > } > > if ($Tk::MMtry::VERSION ge '4.007' && > try_run("config/has_png.c",[$libpng_cflags],[$libpng_libs])) > > And config/has_png.c calls zlibVersion(). > > My libpng does not output zlib as build-time dependency: > > # pkg-config --libs libpng > -lpng16 > > I propose to add '-lz' to the $libpng_libs.
This should work now in 804.031_500. perl Makefile.PL now asks "pkg-config zlib" for information, or if this fails just adds -lz. With this change things are working on my Fedora 20 VM. Regards, Slaven