Installing the GD::Graph Perl module on Ubuntu Linux

January 21st, 2008 | Categories: Linux, programming | Tags:

I have a couple of perl projects that make use of the GD::Graph module and I needed to set them up on a new machine. I was expecting to install the module without any problems but I was wrong. With a live internet connection I started off by starting the CPAN shell by typing the following in a bash shell

sudo perl -MCPAN -e shell

Since it was the first time I had run this command on this particular machine I had to answer a lot of questions but simply selected the defaults for everything as this usually works for me. Once in the CPAN shell I entered

install Bundle::CPAN

and selected all of the defaults again. Once the CPAN bundle had finished installing I tried to install GD::Graph by typing

install GD::Graph

but it failed with hundreds of errors – the first of which was

GD.xs:7:16: error: gd.h: No such file or directory

This was fixed with the following apt-get command (in the bash shell)

sudo apt-get install libgd2-xpm-dev

back in the CPAN shell I still couldn’t get GD::Graph to build and I guessed this was because of some left over files from the failed build. I don’t know the command to clean things up inside the CPAN shell and am too lazy to read the docs so I simply went into the .cpan/build directory in my home directory and deleted anything that started with GD – eg

rm -rf GD-2.35-HC_vkB

rm -rf GDGraph-1.44-Evfibe

and so on. Those strings at the end (VkB and so on) look random so they might be different on your machine. Then I went back into the CPAN shell and ran

install GD::Graph

again. There were a few dependencies which the script fetched and installed for me but everything worked smoothly. With a bit of luck these notes will be of use to someone else out there – please let me know if this is the case.

  1. James
    May 20th, 2008 at 16:22
    Reply | Quote | #1

    Thanks that worked for me on Ubuntu 8.04 x86_64

  2. Martin Gerner
    September 8th, 2008 at 16:55
    Reply | Quote | #2

    Thanks, it helped for me as well.

  3. December 1st, 2008 at 17:41
    Reply | Quote | #3

    Thanks, I was having troubles installing GD via CPAN – After installing libgd2-xpm-dev it installed smoothly!

  4. brian
    February 26th, 2009 at 04:47
    Reply | Quote | #4

    worked perfectly. nice doc!

  5. Aaron Guise
    March 10th, 2009 at 05:50
    Reply | Quote | #5

    Worked like a charm, thanks mate!

  6. p cooper
    November 15th, 2009 at 10:59
    Reply | Quote | #6

    Thanks – Im stuck as well – i get this from the commandline

    The following packages have unmet dependencies.
    libgd2-xpm-dev: Depends: libfontconfig1-dev but it is not installable
    Depends: libfreetype6-dev but it is not going to be installed
    Depends: libjpeg62-dev but it is not installable
    Depends: libpng12-0-dev but it is not installable
    Depends: libx11-dev but it is not installable
    Depends: libxpm-dev but it is not installable
    Depends: zlib1g-dev but it is not installable

    when i try and do them individually , i get a an ‘uresolvable dependencies’ message . is there a dev repository that needs to be activated ?

  7. February 3rd, 2010 at 19:32
    Reply | Quote | #7

    why not install libgd-graph-perl?

  8. February 4th, 2010 at 10:49
    Reply | Quote | #8

    Hi Matthias

    I wrote this post quite a long time ago so I can’t recall what was going through my mind at the time. Either the libgd-graph-perl package didn’t exist back then or I simply didn’t know about it. Maybe I needed a newer version than the one in the repo…who knows :)

    Anyway..thanks for your comment.

    Cheers,
    Mike

  9. Myra
    October 7th, 2010 at 15:34
    Reply | Quote | #9

    thanks this really came in handy

  10. Del
    December 9th, 2010 at 21:33

    Many thanks – this worked for me on Hardy Heron:

    $>sudo perl -MCPAN -e shell
    $>install Bundle::CPAN

    accepted all defaults

    $>sudo apt-get install libgd-graph-perl

  11. Chris
    September 19th, 2012 at 22:28

    Helped a bunch!

  12. Mariano
    February 9th, 2013 at 13:00

    Thank you for sharing your experience. I wasn’t able to install GD or libgd, you helped a lot!

  13. George
    April 6th, 2016 at 17:58

    Eight years later and this post was still hugely helpful. Ubuntu 14.04

  14. Allen
    June 21st, 2016 at 07:08

    Helped a lot !

  15. Antonio Rodríguez
    April 24th, 2018 at 06:50

    It worked for me. Very helpful