DynaLoader problem, (Extending Perl)

DynaLoader problem, (Extending Perl)

am 02.06.2005 22:14:10 von shrike

Howdy,

perl, v5.8.6 built for cygwin-thread-multi-64int, On win2k.

I'm trying to create a module for spoofing ^C ^X ^V characters being
sent to the active window in the Win32 environment (Cut Copy Paste).
The test files are called Win32::Clipboard::Cut right now, which will
surely change.

I've managed to get an xs file to build and install using the book
"Extending and Embedding perl".

The following testscript: ##########################################

#!/usr/bin/perl -w
use Win32::Clipboard::Cut ;
my $o = Win32::Clipboard::Cut->new() ;

Yields: ############################################################ #

Can't locate object method "bootstrap" via package
"Win32::Clipboard::Cut" (perhaps you forgot to load
"Win32::Clipboard::Cut"?) at
/usr/lib/perl5/site_perl/5.8/cygwin/Win32/Clipboard/Cut.pm line 13.
Compilation failed in require at ./testcut line 2.
BEGIN failed--compilation aborted at ./testcut line 2.

Debug Yields: ########################################################

Unable to connect to remote host: 127.0.0.1:2000
Compilation failed in require.
at ./testcut line 0
main::BEGIN() called at /usr/lib/perl5/5.8/perl5db.pl line 0
eval {...} called at /usr/lib/perl5/5.8/perl5db.pl line 0
BEGIN failed--compilation aborted.
at ./testcut line 0
Can't use an undefined value as a symbol reference at
/usr/lib/perl5/5.8/perl5db.pl line 7495.
at /usr/lib/perl5/5.8/perl5db.pl line 7495
DB::print_help('Debugged program terminated. Use B to quit
or B to res...') called at /usr/lib/perl5/5.8/perl5db.pl line 2035
DB::DB called at /usr/lib/perl5/5.8/perl5db.pl line 9421
DB::fake::at_exit() called at /usr/lib/perl5/5.8/perl5db.pl
line 8993
DB::END() called at ./testcut line 0
eval {...} called at ./testcut line 0
END failed--call queue aborted.
at ./testcut line 0

Cut.pm ###########################################################

package Win32::ClipBoard::Cut ;

BEGIN {
use Exporter ; # to export the constants to the main:: space
use DynaLoader ; # to dynuhlode the module.
}

use strict ;

our $VERSION = '0.01' ;
our @EXPORT_OK = qw/ cut / ;

bootstrap Win32::Clipboard::Cut $VERSION ;

sub new { return bless(\{}) ; }


1 ;

Cut.xs ######################################################

#include
#include
#include
#include
#include

#define __TEMP_WORD WORD /* perl defines a WORD, yikes! */

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

void cut(void)
{
printf("hello\n") ;
keybd_event(50, 0, 0, 0) ;
}

#####################################################

The call to bootstrap is what's failing. If I have the module call
bootstrap explicitly in the dynaloader namespace it still fails. What
spooked me was the loopback connection on port 2000. Whats that?

Any help or even guesses would be appreciated right now.

-Thanks in advance!
-Matt

Re: DynaLoader problem, (Extending Perl)

am 03.06.2005 05:36:36 von Sisyphus

wrote in message
news:1117743250.579863.191320@f14g2000cwb.googlegroups.com.. .
>
> The following testscript: ##########################################
>
> #!/usr/bin/perl -w
> use Win32::Clipboard::Cut ;
> my $o = Win32::Clipboard::Cut->new() ;
>
> Yields: ############################################################ #
>
> Can't locate object method "bootstrap" via package

[snip]

> Cut.pm ###########################################################
>
> package Win32::ClipBoard::Cut ;
>
> BEGIN {
> use Exporter ; # to export the constants to the main:: space
> use DynaLoader ; # to dynuhlode the module.
> }
>
> use strict ;
>
> our $VERSION = '0.01' ;
> our @EXPORT_OK = qw/ cut / ;

our @ISA = qw(Exporter DynaLoader);

>
> bootstrap Win32::Clipboard::Cut $VERSION ;
>
> sub new { return bless(\{}) ; }
>
>
> 1 ;
>

I think it's just that you've forgotten about @ISA. (If I remove that line
from my modules, I get a very similar error.)

Cheers,
Rob

Re: DynaLoader problem, (Extending Perl)

am 04.06.2005 17:55:56 von shrike

Sisyphus wrote:
> wrote in message
> news:1117743250.579863.191320@f14g2000cwb.googlegroups.com.. .
> >
[SNIP]
> >
>
> I think it's just that you've forgotten about @ISA. (If I remove that line
> from my modules, I get a very similar error.)
>
> Cheers,
> Rob

Howdy,

No such luck. I thought it might have to do seeing the files properly
because of the NTFS filesystem. Reinstalled on FAT32, and the problem
persists. I have added @ISA and now the module looks so:

##############################################

package Win32::ClipBoard::Cut ;

BEGIN {
use Exporter ; # to export the constants to the main:: space
use DynaLoader ; # to dynuhlode the module.
our @ISA = qw(Exporter DynaLoader) ;
}

our $VERSION = '0.01' ;
our @EXPORT_OK = qw(cut) ;

use strict ;


bootstrap Win32::Clipboard::Cut $VERSION ;

sub new { return bless(\{}) ; }

1 ;

##########################################################

Any help appreciated.
-Thanks
-Matt

Re: DynaLoader problem, (Extending Perl)

am 04.06.2005 20:07:40 von shrike

shrike@cyberspace.org wrote:
> Sisyphus wrote:
> > wrote in message
> > news:1117743250.579863.191320@f14g2000cwb.googlegroups.com.. .
> > >
> [SNIP]
> > >
> >
> > I think it's just that you've forgotten about @ISA. (If I remove that line
> > from my modules, I get a very similar error.)
> >
> > Cheers,
> > Rob
>
> Howdy,
>
> No such luck. I thought it might have to do seeing the files properly
> because of the NTFS filesystem. Reinstalled on FAT32, and the problem
> persists. I have added @ISA and now the module looks so:
>
> ##############################################
>
> package Win32::ClipBoard::Cut ;
>
> BEGIN {
> use Exporter ; # to export the constants to the main:: space
> use DynaLoader ; # to dynuhlode the module.
> our @ISA = qw(Exporter DynaLoader) ;
> }
>
> our $VERSION = '0.01' ;
> our @EXPORT_OK = qw(cut) ;
>
> use strict ;
>
>
> bootstrap Win32::Clipboard::Cut $VERSION ;
>
> sub new { return bless(\{}) ; }
>
> 1 ;
>
> ##########################################################
>
> Any help appreciated.
> -Thanks
> -Matt

Doh!

Figured it out, I was missing the second block with the MODULE and
PACKAGE lines. I guess these are needed for the DynaLoader.

For those that find this thread later, download the example sources
from manning.com/jenness and build the package from chapter 2.2. Then
take lines OUT instead of just putting new ones in to see what breaks
what. Much easier that way. Then you'll know what you must add for each
new function.

-Thanks
-Matt