Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-09-2009, 11:04 AM   #1
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Rep: Reputation: 31
Question 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.

Last edited by exceed1; 05-09-2009 at 11:06 AM.
Old 05-09-2009, 01:05 PM   #2
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,486

Rep: Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232
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.

Last edited by knudfl; 05-09-2009 at 01:14 PM.
Old 05-09-2009, 01:34 PM   #3
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 05-09-2009 at 01:40 PM.
Old 05-10-2009, 10:20 AM   #4
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
Old 05-11-2009, 02:24 PM   #5
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
Thanks for the answers

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sound and Graphics not working in Intel D101GGC with ATI graphics and Realtek audio sanu1 Linux - Hardware 2 12-28-2008 07:29 PM
what graphics lib do you use? websinger Programming 2 09-07-2006 09:15 AM
Trying to get Mesa3D graphics lib to work fatherg Programming 5 07-12-2004 01:29 AM
My Fedora 1.0 QT lib is not working linuxlah Fedora 3 01-14-2004 07:36 PM
installing lib or libraries or *.so is not working laxguy1515 Linux - General 2 06-06-2003 09:48 PM

All times are GMT -5. The time now is 07:50 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration