jobsworth has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monks,

My web service provider has just upgraded and Perl no longer has GD installed. It has a cpanel and allows a customer to install Perl modules only the C compiler is not available. In the past I have managed to install Perl modules by creating a folder called lib and copying the .pm files to it.
use lib '/home/myaccount/public_html/lib/'; works well but not for GD.pm and the folder GD.

I notice that GD.pm has 4 require statements:-
require FileHandle;
require Exporter;
require DynaLoader;
require AutoLoader;

So i have also copied FileHandle.pm, Exporter.pm and AutoLoader.pm to my lib folder. DynaLoader is something different @ISA = qw(Exporter DynaLoader);. Or maybe there is a Dynaloader.pm. It was very difficult to find the other 3 .pm files on my Debian system. I once worked on a computer telephone hot line service and found that with most customers all I had to do was listen and in framing the question the customer would provide the answer.

My test program is:-

#!/usr/bin/perl use CGI qw(:standard); print "Content-type: text/html\n\n"; $| = 1; open (STDERR, ">&STDOUT"); use CGI::Carp qw(fatalsToBrowser); use lib '/home/myaccount/public_html/lib'; use GD;

The output is:-
Can't locate loadable object for module GD in @INC (@INC contains: /home/myaccount/public_html/lib /usr/local/lib64/perl5 etc. Compilation failed in require at test.cgi line 8.

Since GD.pm is only a wrapper for libgd do I not need to put libgd somewhere like /usr/bin? Only as a customer I have no access to /usr/bin. I think you get the idea that the problem is goung around in circles and so I have come to you.

I run Debian, Apache2 and Perl 14.

My web service provider runs Linux Apache2 and Perl 10. GD works great on my system. It makes no difference which version of GD I copy to /lib.

My web service provider is http://www.dotpromotion.net/

It might be easier to change my web service provider.

Hello monks - what do think. Yes I know copying a module from one system to another is not a good idea but what can I do?

Replies are listed 'Best First'.
Re: GD on Mediacraft
by jmacloue (Beadle) on Feb 21, 2015 at 08:14 UTC

    Your approach works for pure-Perl modules but just copying a GD.pm won't work here as actually it is a wrapper for a shared library saved under architecture-dependent directory. It will be named GD.so and you will definitely need it as well. But beware: things are not going to be easy, 99% chance GD.so taken from your workstation won't work on the hosting server.

    The reason is that «Linux» is a very broad description of what OS does your workstation and hosting server use. You may note that they are quite different (e.g., Perl version), even the architecture may differ. If you are using 32-bit system and they use 64-bit on the server — the reason is obvious, for example.

    Another trouble is shared libraries. The set of them on your workstation and hosting server is different, and GD.so linked against your set may not work on the server — some libraries may be missing and some may have incompatible versions. It is (or, to be more precise, I see no reason why it shouldn't be) possible to build GD.so so that it doesn't use any external libraries but the memory footprint of it will be horrible, and also it will need some knowledge of Linux internals to do so. Another option is to obtain a build environment compatible with OS used on hosting server, build GD.so there and use it. However if your hosting server lacks, e.g., libfontconfig.so — you are still in trouble.

    So, in short: rather then trying to use a binary module all by yourself just ask hosting guys politely to install the module for you, and if they refuse — look for another hosting provider.

Re: GD on Mediacraft
by bitingduck (Deacon) on Feb 21, 2015 at 06:29 UTC

    Can you install to /usr/local/lib?

    You then have to do something like "export LD_LIBRARY_PATH = /usr/local/lib:$LD_LIBRARY_PATH" so that it's findable.

      i do not think i can install to /usr/local/lib but i will investigate. you have given me a fresh idea. /usr/local is a sytem folder and not one of mine in public_html. thank you for the idea.