-   Programming (
-   -   GD graphics lib. not working after install. (

exceed1 05-09-2009 11:04 AM

GD graphics lib. not working after install.

I installed GD graphics lib since i was going to generate some graphs using perl. I installed the GD module and used some sample code to test it out, but when i run in on my webserver i just get this instead of a picture (i have mod_perl installed in apache and its working fine with all other perl scripts):

‰PNG  ��� IHDR���d���d��z‹MQ���PLTE�������Ž~���tRNS�@f��IDATH‰TKn0`‘#@–.r„zŽ€Tg$˜S,8BUo{آ•:1/~žyckŠ^œqpA?^�p- A“&Œf4Wӏ—Ž—hq³Ž4' _QoŽœ‰{a)Ӹfš‡^B:jR˜h† Hկ5QH%ŽnqnŸ~_—G"ڡ·)„*“„ 8A
So it would probably seem like GD isnt installed, but when i check with the CPAN shell i get this:

cpan[1]> install GD
CPAN: Storable loaded ok (v2.18)
Going to read /home/exceed/.cpan/Metadata
  Database was generated on Sat, 09 May 2009 00:27:02 GMT
GD is up to date (2.41).


And when i use this command "perl -MGD" it shows that the module is installed and should be working properly.

I have installed libpng/libpng-dev, libgd2-xdm/libgd2-xdm-dev as well as other needed libraries before installation, so i cant imagine what this can be.

Everything ran fine when compiling and installing except the "make test" which isnt necessary, but i guess that the module wont work if the "make test" fails ?

This was the output from the "make test" command:

$ sudo 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/' for module GD: ./blib/arch/auto/GD/ failed to map segment fr
om shared object: Operation not permitted at /usr/lib/perl/5.10/ line 196.
 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.
        Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 1-12
        Failed 12/12 tests, 0.00% okay
t/Polyline....Can't load '/home/exceed/.cpan/build/GD-2.41-hsZ1xG/blib/arch/auto/GD/' for module GD: /home/exceed/
.cpan/build/GD-2.41-hsZ1xG/blib/arch/auto/GD/ failed to map segment from shared object: Operation not permitted a
t /usr/lib/perl/5.10/ line 196.
 at /home/exceed/.cpan/build/GD-2.41-hsZ1xG/blib/lib/GD/ line 45
Compilation failed in require at /home/exceed/.cpan/build/GD-2.41-hsZ1xG/blib/lib/GD/ line 45.
BEGIN failed--compilation aborted at /home/exceed/.cpan/build/GD-2.41-hsZ1xG/blib/lib/GD/ line 45.
Compilation failed in require at t/Polyline.t line 10.
BEGIN failed--compilation aborted at t/Polyline.t line 10.
        Test returned status 2 (wstat 512, 0x200)
        Failed 1/1 tests, 0.00% okay
Failed Test  Stat Wstat Total Fail  List of Failed
t/GD.t          2  512    12  23  1-12
t/Polyline.t    2  512    1    2  1
Failed 2/2 test scripts. 13/13 subtests failed.
Files=2, Tests=13,  0 wallclock secs ( 0.08 cusr +  0.00 csys =  0.08 CPU)
Failed 2/2 test programs. 13/13 subtests failed.
make: *** [test_dynamic] Error 2

So it seems like its not able to load a shared library, but it should be able to do this because the shared object is present and im running this installation with sudo privileges.

This is a little wierd since the "make Makefile.PL" as well as the compilation ("make") and installation ("make install") is working without problems and the CPAN shell is also reporting that everything seems to be fine.

Can someone please tell me why the GD module is not working here and why im getting the wierd letters instead of a picture?

All help is appericiated.

knudfl 05-09-2009 01:05 PM

Debian - Ubuntu, related packages :

libgd2-xpm libgd2-xpm-dev libgd-tools libgd-gd2-perl

But the missing one could be 'php5-gd' ?

'libgdchart-gd2-xpm' :
A library for generating nice 2d and 3d graphs with the use of GD.

paulsm4 05-09-2009 01:34 PM

Hi -

One of the first things we need to figure out is whether this is:
a) a problem with GD/your GD install
... or ...
b) an Apache/Apache configuration issue

1. Try out "GD::Simple"", and see if it works (independent of trying to display anything from a web browser):

2. Here's a more elaborate example:

It's not good that "make test" fails, but it's entirely possible that GD is working correctly anyway. Please try either of the above links to verify the basic install, and please post back what you find.

Thanx in advance .. PSM

theNbomr 05-10-2009 10:20 AM

It looks to me like you are generating a proper PNG image file, but transmitting it without the proper header. If the image is being transmitted as an inline image embedded in an HTML page, it might look correct. My guess is that you are calling the image directly by having your CGI transmit the PNG image as a full page. In this case, you will need to have the CGI prefix the proper header, at minimum:

    print "Content-Type: image/png\n\n";
--- rod.

exceed1 05-11-2009 02:24 PM

Thanks for the answers :)

As theNbomr suggested, "content-type: image/png\n\n" worked nicely, it produced an image instead of just text.

All times are GMT -5. The time now is 06:05 PM.