j***@gmail.com
2006-09-19 14:40:20 UTC
Hi all
I have a problem that I am running into while using Perl XS to build
an interface to my C++ library. This is on a windows machine with perl
5.6.1. I was able to use PerlXS to expose out different 'c++
classes' that my API supports. I wrote the .XS files for each of
these objects and now I am able to make a simple test.pl file and use
these objects from Perl. The problem comes when I try to use more than
1 object (module) in a single .pl file. Here would an example
========== working example perl script ================
use lib "C:/Documents and Settings/myusername/Desktop/perl
experiment/api";
use MyDataReader;
my $dr = new MyDataReader("hsd_demo_pre");
$dr->execQuery("select * from table");
print "fields: " . $dr->getFieldCount() . "\n";
================== perl script giving problem =============
use lib "C:/Documents and Settings/myusername/Desktop/perl
experiment/api";
use MyDataReader;
use MyAdmin; # Adding this line gives problems
my $dr = new MyDataReader("hsd_demo_pre");
$dr->execQuery("select * from bug");
print "fields: " . $dr->getFieldCount() . "\n";
========= Error Message ==================
C:\Documents and Settings\myusername\Desktop\perl experiment\api>perl
test.pl
Can't load 'C:\Documents and Settings\ myusername \Desktop\perl
experiment\api/5.6.1
/MyAdmin.dll' for module MyAdmin: load_file:Attempt to access invalid
address at C
:/Perl/lib/DynaLoader.pm line 206.
Compilation failed in require at test.pl line 11.
BEGIN failed--compilation aborted at test.pl line 11.
So the problem shows up when I use more than one 'use' statements
in a perl script. Its important to note here that I can use the
'MyAdmin' module by itself just fine. So its not aproblem with that
module. The problem is only when I try to use more than 1 module in a
single perl script.
==================== Makefile.PL ===================
use ExtUtils::MakeMaker;
$CC = 'cl';
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile( 'NAME' => 'MyDataReader',
'VERSION' => '0.10',
'DEFINE' => '-TP -EHsc', # e.g., '-DHAVE_SOMETHING'
'CC' => $CC,
'LDDLFLAGS' => '-nologo -libpath:"C:\Perl\lib\CORE"
-machine:x86',
'LIBC' => 'msvcrtd.lib',
'LDLOADLIBS' => 'oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrtd.lib',
'CCFLAGS' => '-nologo -O1 -MDd -DNDEBUG -DWIN32 -D_CONSOLE
-DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
'LD' => '$(CC)',
'XSOPT' => '-C++',
'OPTIMIZE' => '-O1 -MDd -DNDEBUG',
'PERM_RW' => '664',
'PERM_RWX' => '775',
'TYPEMAPS' => ['perlobject.map'] ,
'INC' => "-Iinclude",
'MYEXTLIB' => 'lib\myexternalapi.lib'
);
========== end =========
I have a problem that I am running into while using Perl XS to build
an interface to my C++ library. This is on a windows machine with perl
5.6.1. I was able to use PerlXS to expose out different 'c++
classes' that my API supports. I wrote the .XS files for each of
these objects and now I am able to make a simple test.pl file and use
these objects from Perl. The problem comes when I try to use more than
1 object (module) in a single .pl file. Here would an example
========== working example perl script ================
use lib "C:/Documents and Settings/myusername/Desktop/perl
experiment/api";
use MyDataReader;
my $dr = new MyDataReader("hsd_demo_pre");
$dr->execQuery("select * from table");
print "fields: " . $dr->getFieldCount() . "\n";
================== perl script giving problem =============
use lib "C:/Documents and Settings/myusername/Desktop/perl
experiment/api";
use MyDataReader;
use MyAdmin; # Adding this line gives problems
my $dr = new MyDataReader("hsd_demo_pre");
$dr->execQuery("select * from bug");
print "fields: " . $dr->getFieldCount() . "\n";
========= Error Message ==================
C:\Documents and Settings\myusername\Desktop\perl experiment\api>perl
test.pl
Can't load 'C:\Documents and Settings\ myusername \Desktop\perl
experiment\api/5.6.1
/MyAdmin.dll' for module MyAdmin: load_file:Attempt to access invalid
address at C
:/Perl/lib/DynaLoader.pm line 206.
Compilation failed in require at test.pl line 11.
BEGIN failed--compilation aborted at test.pl line 11.
So the problem shows up when I use more than one 'use' statements
in a perl script. Its important to note here that I can use the
'MyAdmin' module by itself just fine. So its not aproblem with that
module. The problem is only when I try to use more than 1 module in a
single perl script.
==================== Makefile.PL ===================
use ExtUtils::MakeMaker;
$CC = 'cl';
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile( 'NAME' => 'MyDataReader',
'VERSION' => '0.10',
'DEFINE' => '-TP -EHsc', # e.g., '-DHAVE_SOMETHING'
'CC' => $CC,
'LDDLFLAGS' => '-nologo -libpath:"C:\Perl\lib\CORE"
-machine:x86',
'LIBC' => 'msvcrtd.lib',
'LDLOADLIBS' => 'oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrtd.lib',
'CCFLAGS' => '-nologo -O1 -MDd -DNDEBUG -DWIN32 -D_CONSOLE
-DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
'LD' => '$(CC)',
'XSOPT' => '-C++',
'OPTIMIZE' => '-O1 -MDd -DNDEBUG',
'PERM_RW' => '664',
'PERM_RWX' => '775',
'TYPEMAPS' => ['perlobject.map'] ,
'INC' => "-Iinclude",
'MYEXTLIB' => 'lib\myexternalapi.lib'
);
========== end =========