Subject: | Can't get to build with PNG on Windows without strange workaround |
Date: | Mon, 16 Jan 2012 19:04:53 +0100 |
To: | <bug-Imager [...] rt.cpan.org> |
From: | "Neubauer, Ralf" <Ralf.Neubauer [...] wido.bv.aok.de> |
I am struggling to get PNG support under Windows:
libpng needs zlib. I use the official DLL from
http://zlib.net/zlib125-dll.zip , which gives me a lib\libzdll.a (via
the recommended "copy lib\zdll.lib lib\libzdll.a"). Thus i get a
libpng.a, which is only linkable together with libzdll. I.e. if you use
-lpng, you also have to pass -lzdll, or the zlib symbols will be
missing. (Maybe I'm doing something wrong in this step; as I want/have
to build with the compiler perl was built with (MinGW), I can't use the
windows build commands distributed with
http://download.sourceforge.net/libpng/lpng157.zip).
Normally i would just set IM_LFLAGS=-lzdll, but Imager\Probe.pm totally
ignores the LFLAGS. And Win32 won't get detected with -lzdll on the
command line, because the IM_LIBPATH is ignored by the Win32 probing
code, apparently. So I resorted to this workaround:
Imager 0.86 and before:
perl -i.bak -pe "$q='\\'.chr(34); s/($q-l\$libbase)($q)/$1 -lzdll$2/"
lib\Imager\Probe.pm
(Note the difficulties with escaping the " for the CMD shell and for the
perl running under the shell)
Imager 0.87:
perl -i.bak -pe "$q='\\'.chr(34);
s/($q-l\$req->\{libbase\})($q)/\$req->\{libbase\} eq 'png' ? $1 -lzdll$2
: $1$2/; s/($q-l\$base)($q)/($1$2, \$base eq 'png' ? ($2-lzdll$2) :
())/" lib\Imager\Probe.pm
Note the special casing for png. Do you think this could be made easier?
E.g. with a zoo of per library environment variables like IM_LFLAGS_PNG,
which get evaluated for building and for probing?
Ralf