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

I'm having some problems trying to use GD library on server.

First of all, I realized this library was not present on my server. Not bad (well, GD is part of MacPerl standard distribution; I thought it could be the same with Linux). I've downloaded a version of GD library and I've tried to compile it (in my own directory, cause I haven't root privileges).

Now comes the annoying part.
Trying to load the library, perl answers:
Can't load module GD, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the GD module statically linked into it.)
In GD.pm documentation, I've read:
If the make and install all seem to go well but you get errors like "Fatal error: can't load module GD.so", or "Fatal error: unknown symbol gdFontSmall" when you try to run a script that uses GD, you may have problems with dynamic linking. Check whether other dynamically-linked Perl modules such as POSIX and DB_File run correctly.

I tried to use POSIX library, and perl does not complain. I'd be glad if I have not to reinstall Perl. Could someone help me? When you want. I'm not holding my breath :)

larsen
-- "Fatti non foste a viver come bruti"

Replies are listed 'Best First'.
Re: Problems compiling GD
by ahunter (Monk) on Oct 05, 2000 at 16:42 UTC
    Um, I think you're going to have to reinstall perl :-)

    Your version of Perl was not compiled with support for loading modules written in C (or other languages) at runtime... A lot of modules that have to call routines from C libraries or otherwise do things that are not easy to do from perl itself come with these modules, and usually Perl for a modern Unix (or Linux ;-) will be built with support for loading these modules... You can turn it off at compile time (I think if support is found, the option is turned on if you accept the defaults). It's probably best to compile it yourself so you get it working the way you want, rather than install using a binary packaging system like RPM. Once you've got dynamic loading turned on, you shouldn't need to recompile Perl again to add new modules like this.

    As to POSIX, it's a standard module, and will be statically linked if dynamic loading is turned off, so as a test of whether or not dynamic loading is working, it's a tad limited.

    Andrew.

Re: Problems compiling GD
by swiftone (Curate) on Oct 05, 2000 at 17:50 UTC
    To be a bit more verbose on the installation:

    It's fairly painless on a modern* Linix system. A standard* ./configure && make && make install.

    The configure gives you a long list of questions, to which you can almost always just pick the default. (You may want to watch for the dynamic linking option, but I'm betting it will be enabled by default)
    Note that an installation of a different version of perl will NOT see any modules you installed for a different version (such as GD). Also note that while 5.6 (for example), has a lot of common modules included, many others that are commonly used are not included. (It's on the to-do list for 6.0, and presumably the 5.7/5.8 series) Usually after I do an install, I do a 'perl -MCPAN -eshell' (which involves another accept-the-defaults config), and install a short list of modules.
    Also note that a distributions installation may not be in the "standard" place (/usr/bin/perl, /usr/local/bin/perl). You may want to uninstall any perl RPM/debs you have before installing the new version. (But there are probably a lot of dependancies based on perl, so maybe not.)

    *Can we use these words in relation to Linix yet?

Re: Problems compiling GD
by vaevictus (Pilgrim) on Oct 05, 2000 at 19:12 UTC
    actually... the i experienced this too... the issue can be resolved by applying a patch to GD... I unfortunately don't remember where it is...
    This patch allows you to build a GD.so ... a shared library, instead of GD.a, a static library... as soon as you build the shared version of GD, your problems will be over.

    I'll update when i find the code