PDA

View Full Version : Installing Perl GD module with CPAN



sonavor
03-26-2006, 01:44 AM
Per the excellent section: Installing Perl modules with CPAN (http://forums.westhost.com/showthread.php?t=6859&highlight=perl+CPAN) in this forum section I have successfully installed several Perl modules that I needed (AppConfig, DBI, Date::Format, Mail::Mailer). I put them in a directory called perl5add (/usr/local/perl5add) and put an export statement in my .bashrc file for it (export PERL5LIB=/usr/local/perl5add/lib). However, I need to install the GD Perl module as well but I run into errors when running perl -MCPAN -e 'install "GD"'.

The questionable output I see is after the tarball is downloaded and after the CPAN.pm: Going to build L/LD/LDS/GD-2.32.tar.gz message. I get this series of lines -
If you experience compile problems, please check the @INC, @LIBPATH and @LIBS
arrays defined in Makefile.PL and manually adjust, if necessary.

Checking if your kit is complete...
Looks good
Unrecognized argument in LIBS ignored: '/usr/local/lib/libiconv.so'
Unrecognized argument in LIBS ignored: '-Wl,-rpath'
Unrecognized argument in LIBS ignored: '-Wl,/usr/local/lib'
Writing Makefile for GD
...then a bunch of output lines that look okay and finally...
/bin/make -- OK

So I'm not sure if the Unrecognized argument messages are the issue but the next section of the install is where the installation indicates a fail -

Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/GD..........Can't load './blib/arch/auto/GD/GD.so' for module GD: /usr/local/lib/libgd.so.2: undefined symbol: FT_Activate_Size at /usr/local/perl/lib/5.8.7/i686-linux/DynaLoader.pm line 230.
at t/GD.t line 14
Compilation failed in require at t/GD.t line 14.
BEGIN failed--compilation aborted at t/GD.t line 14.
t/GD..........dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 1-12
Failed 12/12 tests, 0.00% okay
t/Polyline....Can't load '/usr/home/[myWestHostAccount]//.cpan/build/GD-2.32/blib/arch/auto/GD/GD.so' for module GD: /usr/local/lib/libgd.so.2: undefined symbol: FT_Activate_Size at /usr/local/perl/lib/5.8.7/i686-linux/DynaLoader.pm line 230.
at /usr/home/[myWestHostAccount]//.cpan/build/GD-2.32/blib/lib/GD/Polyline.pm line 45
Compilation failed in require at /usr/home/[myWestHostAccount]//.cpan/build/GD-2.32/blib/lib/GD/Polyline.pm line 45.
BEGIN failed--compilation aborted at /usr/home/[myWestHostAccount]/.cpan/build/GD-2.32/blib/lib/GD/Polyline.pm line 45.
Compilation failed in require at t/Polyline.t line 10.
BEGIN failed--compilation aborted at t/Polyline.t line 10.
t/Polyline....dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED test 1
Failed 1/1 tests, 0.00% okay
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/GD.t 2 512 12 23 191.67% 1-12
t/Polyline.t 2 512 1 2 200.00% 1
Failed 2/2 test scripts, 0.00% okay. 13/13 subtests failed, 0.00% okay.
make: *** [test_dynamic] Error 2
/bin/make test -- NOT OK
Running make install
make test had returned bad status, won't install without force

I'm not sure if this is a version mismatch between the Perl GD-2.32 module and the version of Perl (v5.8.7) running on the server or some other problem.
Is there a way to specify a different Perl module version in the perl -MCPAN -e 'install "<modulename>"' command?

jalal
03-26-2006, 02:24 AM
It looks like you have an old version of gd installed at:
/usr/local/lib/libgd.so.2
and that is failing the test.

From the output, it seems that the GD library is being built ok, but when the test system runs it is picking up the older library. Maybe you can remove or rename the old one and run the test again?

sonavor
03-26-2006, 01:58 PM
Thanks Jalal. It looks like if I want to update my Perl GD library I'll have to see if WestHost can do it as root.

root 948968 Jan 5 2005 libgd.a
root 750 Jan 5 2005 libgd.la
root 14 May 19 2005 libgd.so -> libgd.so.2.0.0
root 14 May 19 2005 libgd.so.2 -> libgd.so.2.0.0
root 504954 Jan 5 2005 libgd.so.2.0.0

WestHost is the root owner on my VPS.

The reason I am trying to upgrade the Perl GD library is because I am trying to install and configure Bugzilla 2.20. When Bugzilla runs a Perl library compatibility check it flags the GD lib as one that isn't correct. This is the message the Perl check writes out -

The following Perl modules are optional:
Checking for GD (v1.20) not found
Checking for Chart::Base (v1.0) not found
Checking for XML::Parser (any) ok: found v2.34
Checking for GD::Graph (any) not found
Checking for GD::Text::Align (any) not found

The Perl library requirements are a little confusing because while it appears that GD 1.20 is required the resolution is to run perl -MCPAN -e 'install "GD"' which always results in the attempt to upgrade the Perl GD lib to 2.32. I am going to submit that question to the Bugzilla forum.

In the meantime, according to Bugzilla installation instructions, the GD library is an optional item so I am going to continue without it (means I won't have report graphing capabilities I think).

If I get the Perl GD library issue resolved I will post an update. Thanks again for your help and I would like to also thank you for your involvement in the instructions on setting up CVS and xinetd on a WestHost VPS. That was great. I have been running CVS now for several months without any problems.

sonavor
03-26-2006, 09:37 PM
I think that I almost have bugzilla running but there appears to be an issue with the Perl modules I installed earlier not being found when Apache processes a request to the bugzilla web directory where the perl scripts using the modules are located.

Earlier I successfully ran perl -MCPAN -e ’install "Date::Format"’ and it installed into my /usr/local/perl5add directory. After doing that I can run the Bugzilla checksetup.pl script and get a pass indication that the Date::Format Perl module can be found.

After running other Bugzilla installation check routines it appears that everything is in place and Bugzilla should run. However, when I try to access the Bugzilla home directory on my website (http://<myWesthostSite>/bugzilla) I get a 500 Internal Server Error message. The Apache error log contains this -
Can't locate Date/Format.pm in @INC (@INC contains: . /usr/local/perl/lib/5.8.7/i686-linux /usr/local/perl/lib/5.8.7 /usr/local/perl/lib/site_perl/5.8.7/i686-linux /usr/local/perl/lib/site_perl/5.8.7 /usr/local/perl/lib/site_perl) at Bugzilla/Error.pm line 32.
BEGIN failed--compilation aborted at Bugzilla/Error.pm line 32.
Compilation failed in require at Bugzilla/Util.pm line 45.
BEGIN failed--compilation aborted at Bugzilla/Util.pm line 45.
Compilation failed in require at CGI.pl line 43.
BEGIN failed--compilation aborted at CGI.pl line 43.
Compilation failed in require at /var/www/html/bugzilla/index.cgi line 33.
[Sun Mar 26 21:13:11 2006] [error] [client 12.171.188.29] Premature end of script headers: /var/www/html/bugzilla/index.cgi

So it would appear that the location of my added Perl module libraries (in /usr/local/perl5add/lib) are not being found when Apache is processing the request. Am I missing an entry in the httpd.conf file that needs to define where the added Perl module libraries are?

jalal
03-26-2006, 11:37 PM
You have the locations of the new libraries listed in /.bashrc but this file is only read by a login shell. Programs such as Apache won't read that file and won't find the libraries.

Possibly this may help:
http://perl.apache.org/docs/1.0/guide/porting.html#_INC_and_mod_perl

HTH

sonavor
03-27-2006, 01:50 AM
Cool, that looks promising. I'll have to finish working on this after some sleep. My initial attempt didn't work though. I tried adding this to my httpd.conf file -
SetEnv PERL5LIB "/usr/local/perl5add/lib"
It didn't fix the problem.

sonavor
03-27-2006, 11:50 AM
I'm stuck right now trying to get my added Perl modules into the Apache environment (when Apache starts).

After doing Google searches I found that some people suggessted the SetEnv in httpd.conf worked while other people suggested using PerlSetEnv. Since using SetEnv PERL5LIB "/usr/local/perl5add/lib" didn't work for me I tried the second suggestion. In my httpd.conf I have this -

<IfModule mod_perl.c>
Alias /mod-perl /var/www/cgi-bin/mod-perl
<Location /mod-perl>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSetEnv PERL5LIB "/usr/local/perl5add/lib"
Options +ExecCGI
</Location>
</IfModule>

/usr/local/perl5add/lib is where I had CPAN build and place the libraries of my additional Perl modules.
Unfortunately the PerlSetEnv setting didn't help. My Perl scripts that try to run when accessing them from the web don't know where necessary Perl modules are.

In a shell, though, the exported PERL5LIB works fine and I get this when I run perl -V

%ENV:
PERL5LIB="/usr/local/perl5add/lib"
@INC:
/usr/local/perl5add/lib/i686-linux
/usr/local/perl5add/lib
/usr/local/perl/lib/5.8.7/i686-linux
/usr/local/perl/lib/5.8.7
/usr/local/perl/lib/site_perl/5.8.7/i686-linux
/usr/local/perl/lib/site_perl/5.8.7
/usr/local/perl/lib/site_perl
.

jalal
03-27-2006, 01:31 PM
Just a guess, but maybe PerlSetEnv shouldn't be inside a Location directive, otherwise it only applies to that location.
And remember to restart apache after changing httpd.conf (or at least, using '/etc/rc.d/init.d/httpd graceful')

sonavor
03-27-2006, 02:03 PM
Originally I tried the PerlSetEnv PERL5LIB "/usr/local/perl5add" after the SetEnv PERL5LIB "/usr/local/perl5add" didn't work. I placed those near the end of the Apache httpd.conf file (not at the same time of course).

While the SetEnv just didn't work, the PerlSetEnv caused my Apache server to not run. After that I found an example where the PerlSetEnv was used in the <Location /mod-perl> section. It didn't work but Apache still did. From the Apache log though I can see that the Perl @INC variable doesn't include my perl5lib values -

(@INC contains: . /usr/local/perl/lib/5.8.7/i686-linux /usr/local/perl/lib/5.8.7 /usr/local/perl/lib/site_perl/5.8.7/i686-linux /usr/local/perl/lib/site_perl/5.8.7 /usr/local/perl/lib/site_perl)

I read something where the Perl taint setting could be on and preventing the additional library modules to be included but I don't see anything in the httpd.conf file to support that. I don't want to go in and insert use commands in all of the perl scripts. There has to be a way to add them to the Apache environment.

sonavor
03-28-2006, 10:52 AM
Update - It appears that I may have to roll back my Perl 5.8.7 version to Perl 5.6 in order to install Mod Perl and have Apache use my additional Perl modules. From what I have found searching the web, the PerlSetEnv entry I need to use in the Apache httpd.conf file requires Mod Perl. I thought that I had Mod Perl with my Perl 5.8.7 installation but now I realize that I don't. The Mod Perl installation on WestHost is version 1.2.6. It can be installed if I have Perl 5.6 installed but not Perl 5.8.7.

The thing that is confusing to me is this entry in my current httpd.conf file -

<IfModule mod_perl.c>
Alias /mod-perl /var/www/cgi-bin/mod-perl
<Location /mod-perl>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
</Location>
</IfModule>

I can add PerlSetEnv PERL5LIB "/myPerlModulePath" here and my Apache will start up. If I move the PerlSetEnv command to somewhere else in my httpd.conf then Apache won't start and complains that PerlSetEnv is not recognized. Does that mean that the entries in this module are skipped over during the Apache startup? Isn't this httpd.conf definition what tells Apache where to send Perl scripts?

If I don't have Mod Perl installed in Apache isn't there a way to define additional Perl library paths?

sonavor
03-28-2006, 03:25 PM
Update - After realizing that my WestHost VPS with Perl 5.8.7 installed didn't include a mod_perl I decided to uninstall Perl 5.8.7 and use Perl 5.6.0 that is available. With Perl 5.8.7 I had tried SetEnv PERL5LIB /myAdditionalPerlLibPath and PerlSetEnv PERLPERL5LIB /myAdditionalPerlLibPath in the Apache httpd.conf file.

SetEnv had no affect and PerlSetEnv was not recognized by Apache (and prevented Apache from starting).

Now, with Perl 5.6.0 installed I am also able to install Mod Perl 1.2.6. The interesting thing now is that Mod Perl allows me to put PerlSetEnv in my httpd.conf file and it doesn't cause a server error. Unfortunately the PERL5LIB path contents didn't add to the Perl @INC variable.

Good news is the SetEnv command does something now and my PERL5LIB variables do show up in @INC.

As I should have expected, it ends with Bad News...
If I go with Perl 5.6.0 I can't run the SpamAssassin (3.1.0) WestHost provides. Perl version 5.6.0 is also incompatible with Bugzilla 2.20.

sonavor
03-28-2006, 05:15 PM
After uninstalling Perl 5.6.0 and related applications I went back to Perl 5.8.7 so I could get SpamAssassin installed.

I still had my PERL5LIB shell environment variable and the SetEnv entry was still in the httpd.conf file. Amazingly when I run my perl cgi test page from the web I now get my PERL5LIB variables in the Apache environment.

I still haven't got Bugzilla 2.20 running though. I have it configured and all of the configuration tests pass. For some reason the Bugzilla CGI scripts are still not finding my added Perl libraries even though I have tested that the PERL5LIB environment variable is there.

If I solve it I will post a Bugzilla setup how to entry.

sonavor
03-28-2006, 11:47 PM
I never could get the Perl GD (1.20) module installed on my VPS but I was able to get Bugzilla 2.20.1 running.

I have posted my installation steps in this forum here - Installing Bugzilla on a WestHost VPS (http://forums.westhost.com/showthread.php?p=31026#post31026)

Taza
05-14-2006, 09:56 AM
t/Polyline....Can't load '/usr/home/[myWestHostAccount]//.cpan/build/GD-2.32/blib/arch/auto/GD/GD.so' for module GD: /usr/local/lib/libgd.so.2: undefined symbol: FT_Activate_Size at /usr/local/perl/lib/5.8.7/i686-linux/DynaLoader.pm line 230.
at /usr/home/[myWestHostAccount]//.cpan/build/GD-2.32/blib/lib/GD/Polyline.pm line 45


I've been battling with this and have found the cause & solution to this problem.

The WestHost-installed freetype library in /usr/lib is old/not the correct version (it doesn't have FT_Activate_Size). Download and install the latest freetype in /usr/local. Then you have to download and install the gd libraries again (and make sure it picks up the new freetype, i.e. ./configure --prefix /usr/local --with-freetype=/usr/local)

Then you can install the GD Perl module again but you also have to hack the Makefile:
perl Makefile.PL -lib_ft_path=/usr/local -lib_gd_path=/usr/local
cp Makefile Makefile-hacked
### EDIT Makefile-hacked ###
< LD_RUN_PATH = /usr/lib:/usr/local/lib
---
> LD_RUN_PATH = /usr/local/lib:/usr/lib
#
# this makes sure your new freetype is picked up first
####################
cp Makefile-hacked Makefile
make
make test
make install


It's worth getting the freetype stuff installed because
GD::Graph needs it.

good luck!

wick
05-30-2006, 06:08 AM
Got this from Westhost support, worked for me on the two accounts I've tried it on & has less steps than the solution above:

1. edit Makefile.PL (in ~/.cpan/build/GD-2.32/ if you've tried installing via cpan)
2. after the other @LIBS assignment (line 31), add

@LIBS = qw(-liconv -ljpeg -lfreetype -lpng -lz -lm -lgd);

3. save, & then run
perl Makefile.PL
make
make install

...done.

keteracel.com
10-12-2006, 03:12 AM
I just disabled animated gifs and it all works for me (on redhat with GD-2.0.33). I'd also recommend the library fixes above but it wasn't until I got rid of animated gifs (which I'm never going to use!) that it all worked.

Thanks.




################################################## ################################################## ##############
# If build options have not been passed in then prompt for settings
################################################## ################################################## ##############
my ($JPEG, $FT, $XPM, $GIF,$ANIMGIF,$UNCLOSEDPOLY,$FONTCONFIG,$PNG,$FTCI RCLE,$VERSION_33);
if( defined($options) )
{
$JPEG = $options =~ m/JPEG/i;
$FT = $options =~ m/FT|FREETYPE/i;
$XPM = $options =~ m/XPM/i;
$GIF = $options =~ m/GIF/i;
$PNG = $options =~ m/PNG/i;
$ANIMGIF = $GIF && $options =~ m/ANIMGIF/i;
$VERSION_33= $options =~ m/VERSION_33/i;
$UNCLOSEDPOLY = $options =~ m/UNCLOSEDPOLY/i;
$FONTCONFIG = $options =~ m/FONTCONFIG/i;
$FTCIRCLE = $options =~ m/FTCIRCLE/i;
}
else
{
warn "\nPlease choose the features that match how libgd was built:\n";
$JPEG = lc prompt('Build JPEG support?','y') eq 'y';
$PNG = lc prompt('Build PNG support?','y') eq 'y';
$FT = lc prompt('Build FreeType support?','y') eq 'y';
$GIF = lc prompt('Build GIF support?','y') eq 'y';
$ANIMGIF = $GIF && lc prompt('Build support for animated GIFs?','y') eq 'y';
$XPM = $^O !~ /^freebsd|MSWin32$/ && lc prompt('Build XPM support?','y') eq 'y';
}
################################################## ################################################## ##############
$ANIMGIF = 0; #<--- I added this line here