FooBar.o:FooBar.c:(.text+0x1d): undefined reference to `foo'
collect2: ld returned 1 exit status
dmake: Error code 129, while making 'blib\arch\auto\FooBar\FooBar.dll'
####
FooBar.o:FooBar.c:(.text+0x2b): undefined reference to `bar'
collect2: ld returned 1 exit status
dmake: Error code 129, while making 'blib\arch\auto\FooBar\FooBar.dll'
##
##
FooBar.o:FooBar.c:(.text+0x1d): undefined reference to `foo'
FooBar.o:FooBar.c:(.text+0x2b): undefined reference to `bar'
collect2: ld returned 1 exit status
dmake: Error code 129, while making 'blib\arch\auto\FooBar\FooBar.dll'
##
##
=== The Bar Extension ===
-- Bar.pm --
package Bar;
use strict;
require Exporter;
*import = \&Exporter::import;
require DynaLoader;
$Bar::VERSION = '0.01';
DynaLoader::bootstrap Bar $Bar::VERSION;
@Bar::EXPORT = ('bar');
@Bar::EXPORT_OK = ();
sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking
1;
-- Bar.xs --
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
int bar(int x, int y) {
return x * y;
}
MODULE = Bar PACKAGE = Bar
PROTOTYPES: DISABLE
int
bar (x, y)
int x
int y
-- Makefile.PL --
use ExtUtils::MakeMaker;
my %options = (
'NAME' => 'Bar',
'FUNCLIST' => ['boot_Bar', 'bar'],
'VERSION' => '0.01'
);
WriteMakefile(%options);
# Remove the Makefile dependency. Causes problems on a few systems.
sub MY::makefile { '' }
-- test.pl --
use Bar;
$y = 10;
$x = 5;
$z = bar($x, $y);
if($z == 50){print "ok 1\n"}
else {print "not ok 1 $z\n"}
=== The Foo Extension ===
-- Foo.pm --
package Foo;
use strict;
require Exporter;
*import = \&Exporter::import;
require DynaLoader;
$Foo::VERSION = '0.01';
DynaLoader::bootstrap Foo $Foo::VERSION;
@Foo::EXPORT = ('foo');
@Foo::EXPORT_OK = ();
sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking
1;
-- Foo.xs --
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
int foo(int x, int y) {
return x + y;
}
MODULE = Foo PACKAGE = Foo
PROTOTYPES: DISABLE
int
foo (x, y)
int x
int y
-- Makefile.PL --
use ExtUtils::MakeMaker;
my %options = (
'NAME' => 'Foo',
'FUNCLIST' => ['boot_Foo', 'foo'],
'VERSION' => '0.01'
);
WriteMakefile(%options);
# Remove the Makefile dependency. Causes problems on a few systems.
sub MY::makefile { '' }
-- test.pl --
use Foo;
$x = 17;
$y = 31;
$z = foo($x, $y);
if($z == 48){print "ok 1\n"}
else {print "not ok 1 $z\n"}
=== The FooBar Extension ===
-- FooBar.pm --
package FooBar;
use strict;
use lib 'C:/temp/perl/lib';
use Foo;
use Bar;
require Exporter;
*import = \&Exporter::import;
require DynaLoader;
$FooBar::VERSION = '0.01';
DynaLoader::bootstrap FooBar $FooBar::VERSION;
@FooBar::EXPORT = ();
@FooBar::EXPORT_OK = ();
sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking
1;
-- FooBar.xs --
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
int foobar(int x, int y) {
return foo(x,y) + bar(x,y);
}
MODULE = FooBar PACKAGE = FooBar
PROTOTYPES: DISABLE
int
foobar (x, y)
int x
int y
-- Makefile.PL --
use ExtUtils::MakeMaker;
my %options = (
'NAME' => 'FooBar',
'VERSION' => '0.01'
);
WriteMakefile(%options);
# Remove the Makefile dependency. Causes problems on a few systems.
sub MY::makefile { '' }
-- test.pl --
use FooBar;
$x = 5;
$y = 22;
$z = FooBar::foobar($x, $y);
if($z == 137) {print "ok 1\n"}
else {print "not ok 1 $z\n"}