I want to install libpng library on my Mac, which runs under Mavericks. Here is a simple Perl script to check if it is ok:

use GD;
my $gd = GD::Image->new();
my $ok = $gd->can('png') ? 'Yes' : 'No';
print "$ok\n";

Of course, running this script (perl my-test.pl) returns No.

So I followed the documentation here, and I run the following commands:

port install xorg-server
port install xorg-libXmu
port install libxml2
port install libpng

(all of them with sudo). But still, no luck with my test script.

I've tried a manual installation too, with the following command:

cd /usr/local/src
curl --location --output libpng-1.6.8.tar.gz http://download.sourceforge.net/libpng/libpng-1.6.8.tar.gz
tar -xzvf libpng-1.6.8.tar.gz
cd libpng-1.6.8
./configure --prefix=/usr/local/libpng-1.6.8
make install
ln -s libpng-1.6.8 /usr/local/libpng


Unfortunately, the script continues to return No.

Using CPAN, if I try to run install Image::PNG::Libpng, it fails with an error:

Test Summary Report
t/Libpng.t (Wstat: 256 Tests: 20 Failed: 1)
  Failed test:  13
  Non-zero exit status: 1
Files=9, Tests=54,  1 wallclock secs ( 0.08 usr  0.03 sys +  0.51 cusr  0.10 csys =  0.72 CPU)
Result: FAIL
Failed 1/9 test programs. 1/54 subtests failed.
make: *** [test_dynamic] Error 255
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports BKB/Image-PNG-0.20.tar.gz
Running make install
  make test had returned bad status, won't install without force
  Already tried without success
Failed during this command:
 BKB/Image-PNG-0.20.tar.gz                    : make_test NO

Using force install Image::PNG::Libpng doesn't help neither.

Any idea what I'm doing wrong, or what can I do to complete my installation?

Sorry if I missed some details, or logs from commands. Do not hesitate to ask me more details...

1 Answer 1


Did you do the final step of setting up the environment variables and then restarting the shell session before trying your tests?

What does echo $PNG_DIR at the command prompt give you? A blank line or a line containing /usr/local?

  • I've tried to set this PNG_DIR variable, but still it does not work. Jan 16, 2014 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.