Installing the GD::Graph Perl module on Ubuntu Linux
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.
Thanks that worked for me on Ubuntu 8.04 x86_64
Thanks, it helped for me as well.
Thanks, I was having troubles installing GD via CPAN – After installing libgd2-xpm-dev it installed smoothly!
worked perfectly. nice doc!
Worked like a charm, thanks mate!
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 ?
why not install libgd-graph-perl?
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
thanks this really came in handy
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
Helped a bunch!
Thank you for sharing your experience. I wasn’t able to install GD or libgd, you helped a lot!
Eight years later and this post was still hugely helpful. Ubuntu 14.04
Helped a lot !
It worked for me. Very helpful
I am using Mac OS 10.13.6 and trying to install GD module. I follows the instructions above to install libgd-graph-perl. Here is the log:
JosephsBP152018:~ josephtang$ sudo apt-get install libgd-graph-perl
Password:
sudo: apt-get: command not found
JosephsBP152018:~ josephtang$ sudo perl -MCPAN -e shell
cpan shell — CPAN exploration and modules installation (v2.00)
Enter ‘h’ for help.
cpan[1]> install libgd-graph-perl
Reading ‘/Users/josephtang/.cpan/Metadata’
Database was generated on Thu, 16 Aug 2018 01:17:02 GMT
Warning: Cannot install libgd-graph-perl, don’t know what it is.
Try the command
i /libgd-graph-perl/
to find objects with matching identifiers.
Please help