Perl bindings to plasma

Chris Burel chrisburel at gmail.com
Tue Nov 16 18:47:56 CET 2010


Hey guys,
I'm working on getting Perl bindings to Plasma working, so that you
could create plasma widgets in Perl.  However, I'm having trouble
getting things to load properly.

I have a subclass of KPluginFactory that I've called
KPerlPluginFactory.  This is what's responsible for creating a Perl
interpreter and loading up the correct modules, etc.  Then I have a
.desktop file I've placed in share/kde4/services/ that tells plasma an
applet exists, and to load it using kperlpluginfactory.  The plugin
loads successfully, and creates a Perl interpreter just fine.

The problem comes when the Perl code needs to load in more Perl
modules dynamically.  kperlpluginfactory does link to libperl, but
because Plasma doesn't export the symbols of the loaded plugin (aka,
the load hint QLibrary::ExportExternalSymbolsHint is not set when the
plugin is loaded), symbols from the dynamically loaded Perl modules
don't get resolved.  So I get something like this:

> plasmoidviewer perl-hello-plasmoid
Can't load '/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/auto/Devel/Peek/Peek.so'
for module Devel::Peek:
/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/auto/Devel/Peek/Peek.so:
undefined symbol: Perl_runops_standard at
/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/XSLoader.pm line 64.
 at /usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/Devel/Peek.pm line 19
Compilation failed in require at /home/cburel/perlqtinstall//QtGui4.pm line 25.
BEGIN failed--compilation aborted at
/home/cburel/perlqtinstall//QtGui4.pm line 25.
Compilation failed in require at /home/cburel/perlqtinstall//KDEUi4.pm line 23.
BEGIN failed--compilation aborted at
/home/cburel/perlqtinstall//KDEUi4.pm line 23.
Compilation failed in require at
/home/cburel/.kde4/share/apps/plasma_applet_perl_hello_plasmoid/PlasmaAppletPerlHelloPlasmoid.pm
line 10.
BEGIN failed--compilation aborted at
/home/cburel/.kde4/share/apps/plasma_applet_perl_hello_plasmoid/PlasmaAppletPerlHelloPlasmoid.pm
line 10.

I've come up with two workarounds so far.  One is to use LD_PRELOAD to
load libperl.so, which isn't really a solution, but it did work in my
test.  The other is to modify KPluginFactory to have the option of
specifying load hints in the constructor, and then have plasma check
for a key in the .desktop file to determine if the symbols from the
plugin should be exported.

Or maybe there's some other/better way for me to make sure that
loading kperlpluginfactory will export the necessary symbols from
libperl.so?

-Chris


More information about the Plasma-devel mailing list