Question
I’m having a number of problems getting the
ChartPlugin operational and hope for some good advice from those who have been more successful.
I’ve looked at
ThomasWeigert notes in
ChartPluginDev and have browsed though the Support web including
PluginErrorRequiredPerlModuleNotFound, and have followed the tips suggested in those Topics.
The Perl GD module seems to be correctly installed, but accessing either
ChartPlugin or
ChartPluginTests on my server fails with an “Internal Server Error”. An examination of the httpd logs provides the error message:
Can't locate object method "png" via package "GD::Image" at …/twiki/lib/TWiki/Plugins/ChartPlugin/Chart.pm line 1461.
I’ve been digging around in the GD & related modules, but it’s unclear where the method png() is defined and/or inherited from.
Environment
--
BillKanawyer - 06 Apr 2006
Answer
The
GD-2.32/README file provides the primary clue:
4. My scripts fail with "Can't locate object method 'png' via package "GD::Image".
libgd can now be built with support for one or more of the PNG, GIF, XPM or
JPEG formats. If one or more of these formats are not supported by libgd, then
the corresponding GD::Image methods will be unavailable. Unfortunately, many
older scripts assume that the png() method will always be present. You can
work around this issue with code like the following:
my $image = $gd->can('png') ? $gd->png : $gd->gif;
or if you prefer eval {}
my $image = eval {$gd->png} || $gd->gif;
As of libgd 2.0.33, GIF support is always compiled in, so (for the time being!)
this is a safe fallback.
Running
perl Makefile.PL -h provides the additional clue:
# perl Makefile.PL -h
Configuring for libgd version 2.0.33.
Unknown option: h
Usage: perl Makefile.PL [options]
Configure GD module.
Options:
-options "JPEG,FT,PNG,GIF,XPM,ANIMGIF" feature options, separated by commas
-lib_gd_path path path to libgd
-lib_ft_path path path to Freetype library
-lib_png_path path path to libpng
-lib_jpeg_path path path to libjpeg
-lib_xpm_path path path to libxpm
-lib_zlib_path path path to libpng
If no options are passed on the command line. The program will
attempt to autoconfigure itself with the gdlib-config program (present
in GD versions 2.0.27 or later). Otherwise it will prompt for these
values interactively.
Included Features: GD_PNG GD_GIF GD_UNCLOSEDPOLY GD_ANIMGIF GD_FTCIRCLE VERSION_33
GD library used from: /usr/local
If you experience compile problems, please check the @INC, @LIBPATH and @LIBS
arrays defined in Makefile.PL and manually adjust, if necessary.
In my partictular case, the build was looking for libraries in the wrong place.
Because
RedHat
installs most of the required libraries in
/usr/lib
rather then
/usr/local/lib the
gdlib-config tool fails to find the libraries and thus
quietly disables support for those features in the module.
Correcting the library path resolved this issue for me.
--
BillKanawyer - 07 Apr 2006