perl extension promblem Can't find 'boot_<blah>' symbol in .so

J

JNye

I'm attempting to use the perl extension mechanism, h2xs,xsubpp, etc.

I receive this error message at run time:
Can't find 'boot_DefRd2' symbol in
<snipped>/DefRd2/blib/arch/auto/DefRd2/DefRd2.so

DefRd2 is my package.

I have three routines called from a test program, dft.pl:
- a straight perl call to a perl sub DefRd2.pm,
- a call to a C extension, where C code is above the
module/package statement in the xs file
- a linked C call, specified in the xs file but C code is
in an external .o file, linked via OBJECT in Makefile.PL
(this C routine lives in an external file called
LinkedCBasicTest.c)
All three routines require no arguments and return no values.
They simply print a string.

The straight perl call and the in-line C call work fine. The linked C
call fails with the above error message, unless
commented out.

Compilation occurs without any warnings/errors (other than those caused
by stripping out the ABSTRACT to shorten my code included below.)

Does anyone have an idea what I'm doing wrong here? Seems like a
straight forward test, I must be missing some detail somewhere.

At first I thought I was having an issue with dynamic libaries but
what's confusing is that the in-line C code works fine.

So I'm thinking either a MakeMaker misuse or xsubpp switch is missing.

Any thoughts/help would be appreciated.

=======================
Original h2xs invocation was:
h2xs -A -n DefRd2 <= my package name
=======================
DefRd2.xs contents <minus comments and such>:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
void InLineCBasicTest (void) {
printf("In line C basic test output\n");
}
MODULE = DefRd2 PACKAGE = DefRd2

void
InLineCBasicTest()

void
LinkedCBasicTest()
=======================
The test script which contains the calls to straight perl, in-line C
and linked C was invoked as:
perl -Mblib dft.pl
=======================
dft.pl contains:
use strict;
use warnings;
use DefRd2;
&DefRd2::InLineCBasicTest;
&DefRd2::pMPerlBasicTest;
&DefRd2::LinkedCBasicTest;
=======================
DefRd2.pm contains:
package DefRd2;
use 5.008003;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw(

) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(

);
our $VERSION = '0.01';
require XSLoader;
XSLoader::load('DefRd2', $VERSION);
sub PMPerlBasicTest { print "Package perl basic test output\n"; }
1;
=======================
Makefile.PL contains:
use 5.008003;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'DefRd2',
VERSION_FROM => 'lib/DefRd2.pm',
PREREQ_PM => {},
($] >= 5.005 ?
(ABSTRACT_FROM => 'lib/DefRd2.pm',
AUTHOR => 'X X. X <'"x@x>') : ()),
LIBS => [''],
DEFINE => '',
INC => '-I.',
OBJECT => 'LinkedCBasicTest.o',
);
=======================
LinkedCBasicTest.c contains:
#include <stdio.h>
void LinkedCBasicTest (void) {
printf("Lined c basic test output\n");
}
=======================
perl version 5.8.6 <upgraded from 5.8.3>
h2xs version 1.2.3 < same for 5.8.3 and 5.8.6>
on RH Fedora 2
 
S

Sisyphus

JNye said:
I'm attempting to use the perl extension mechanism, h2xs,xsubpp, etc.

I receive this error message at run time:
Can't find 'boot_DefRd2' symbol in
<snipped>/DefRd2/blib/arch/auto/DefRd2/DefRd2.so

DefRd2 is my package.
[snip]

=======================
DefRd2.pm contains:
package DefRd2;
use 5.008003;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw(

) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(

);
our $VERSION = '0.01';
require XSLoader;
XSLoader::load('DefRd2', $VERSION);
sub PMPerlBasicTest { print "Package perl basic test output\n"; }
1;

I would try reverting to DynaLoader (instead of XSLoader) and see if
that fixes the problem. According to 'perldoc XSLoader', "many (most)
features of DynaLoader are not implemented in XSLoader".

Hth.

Cheers,
Rob
 
S

Sisyphus

Sisyphus said:
I would try reverting to DynaLoader (instead of XSLoader) and see if
that fixes the problem. According to 'perldoc XSLoader', "many (most)
features of DynaLoader are not implemented in XSLoader".

Nope - doesn't help. In fact, all I needed to do to get it to work was
delete '#include "ppport.h"' from the XS file and in the Makefile.PL
replace 'LinkedCBasicTest.o' with 'DefRd2.o LinkedCBasicTest.o'.

By default, OBJECT is set to DefRd2.o - but when you specify OBJECT in
the WriteMakefile() section, then DefRd2.o is *replaced* by whatever you
specify - so you need to specify DefRd2.o as well.

Not sure what's going on wrt ppport.h.

(I also needed to fix a few typos in the post - that obviously aren't in
the original.)

Cheers,
Rob
 
J

JNye

XSLoader is the default, at least in my invocation of h2xs.

I'll read through the DynaLoader docs and give it a try.

Thanks for the pointer.
 
J

JNye

Excellent, thanks very much for your time. And my appologies for the
typos in my post, I was trying to be as brief as possible.

I confirmed your diagnosis of OBJECT mis-use in Makefile.PL on my part.


Everything works as expected.

Again, thanks Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top