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

(For those who don't know, Pidgin is the new name of the Gaim IM client, and libpurple the new name of the underlying libgaim library)

I'm on a FC 6 box, and I'm getting the following error when use'ing the Purple module:

[~]$ perl -e'use Purple;' Can't load '/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/a +uto/Purple/Purple.so' for module Purple: /usr/lib/perl5/vendor_perl/5 +.8.8/i386-linux-thread-multi/auto/Purple/Purple.so: undefined symbol: + g_str_hash at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/XSLoader. +pm line 70. at /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/Purple.pm + line 52 Compilation failed in require at -e line 1. BEGIN failed--compilation aborted at -e line 1.

I've searched Google and the Pidgin wiki, but haven't found any solution. g_str_hash is defined in /usr/include/glib-2.0/glib/ghash.h, which I assume is properly found since the compilation does succeed.

An ldd on Purple.so does not show glib2 in the list of libraries though. Should it show up or is the XS loader smart enough to find out what libraries to load some other way?

I tried explicitly linking against the library by adding a -lglib-2.0 to the final line of the .so creation. The resulting so file does show the dependency on glib2 then, but trying to load shows a different error:

[~]$ perl -e'use Purple;' perl: symbol lookup error: /usr/lib/perl5/vendor_perl/5.8.8/i386-linux +-thread-multi/auto/Purple/Purple.so: undefined symbol: purple_perl_ca +llXS

which to me seems to suggest linking in the library this way is not the correct thing to do.

If anything has any insight or suggestions on how to solve this, I'm all ears.

Replies are listed 'Best First'.
Re: Purple/Pidgin perl plugin load error
by Khen1950fx (Canon) on May 20, 2007 at 09:56 UTC
    I tried it and got the same response. I reinstalled pidgin and ran /sbin/ldconfig /usr/local/lib. Then I tried  perl -e 'use Purple;' and got no response. This worked for me:

    perl -e 'use Purple; my $p = Purple->new; print "\n";'

    Basically, the print cmd creates a purple.db using sqlite and prints it to the cwd.

      How did you reinstall it? I tried removing/reinstalling the RPM, installing the source RPM and rebuilding from there, and building directly from the sources. In all three cases I end up with the same error.

      I tried your ldconfig command, but it didn't seem to make a difference.

      As an extra information point, my configure line is: ./configure --with-perl-lib=vendor --prefix=/usr

      Update: I recompiled adding --with-gnu-ld to the configure command line to match the reply below, but the result is still the same. Just to be sure I'll try without the prefix and vendor options.

      Update 2: Can't get Purple from CPAN to install either; it's failing the client tests. I'll just make a C plugin instead until Fedora updates glib/gtk or FC7 comes out.

        I built it directly from the source. My configure line was ./configure --with-gnu-ld. It installed into /usr/local/bin/pidgin and /usr/local/lib/pidgin.

        Update: I downloaded Purple from CPAN.

        Note: The glib and gtk rpms that came with the distribution had some problems, so I downloaded and installed glib2, gtk+ and all the dependencies from source and ran ldconfig on all of them.

Re: Purple/Pidgin perl plugin load error
by zdeqb (Novice) on Jun 11, 2007 at 19:00 UTC

    This is a late reply... but...

    If you do the following, there is no need to links against glib. (Order does matter)

    use Glib; use Purple;

    To get around the purple_perl_callXS error, you have to use LD_PRELOAD='' (or link against purple-2/perl.so, libpurple.so)

    LD_PRELOAD='libpurple.so /location/to/lib/purple-2/perl.so' perl -MGli +b -MPurple ...

    But loading libpurple this way is pointless, since the current perl glue only exists so that a plugin can be written in perl. To actually write a client in perl some more glue is required. I started working on that glue (and it seems to work for me), and posted it at this link (there is an example in the libpurple/plugins/perl/scripts/nullclient.pl file after patching)

      Interesting. Indeed use'ing both Glib and Purple gets rid of the g_str_hash error, but as you say still throws the purple_perl_callXS error.

      Writing a plugin in perl is all I'm really looking for.

        this page this page seems to contain everything that's needed to write one. (It's a little old,but is mostly accurate)