Similar Threads:
1.Perl C, XS help
Hi,
I am trying port an Custom Perl module from one server to another. The
module uses C/XS and was built in 2001/2. I got the source and did
`perl Makefile.PL; make`. There was an error in one .c file:
...
store.c:592: error: 'my_perl' undeclared (first use in this function)
store.c:592: error: (Each undeclared identifier is reported only once
store.c:592: error: for each function it appears in.)
I solved that by adding
'static PerlInterpreter *my_perl;' near the top of the file.
After make distclean; perl Makefile, make and the same error with a
different file. This time however, once I added the static declaration
I got this error:
store.c:13: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
It refers to the static declaration mentioned above.
I am a super newbie when it comes to C and I know this might be
straying OT but does anyone know how I can make this static declartion
in the correct way or perhaps point me to a list that might be able to
help?
Thanx,
Dp.
2.Help w/Class::Date Date.xs
3.Help with xs: converting I32 to int ?
4.Problem using more than 1 module in Windows (XS) - please help
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 bug");
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 =========
5.Help - Perl, XS and global constructors
I have a third-party dynamic library that I'm trying to write an xsub
for. It was written in C++, and it apparently has global constructors
that need to be initialized. Building a static xsub works fine, but
the dynamic build always crashes in one function (naturally, it's a
function that needs to be called before almost all of the others in the
library). With the static build running in wdb, I can actually see
code in the library being called from __do_global_ctors(), but not so
with a dynamic build, so I'm pretty sure it's a constructor problem.
Before I go into the gritty details, let me just ask the basic
question: can a dynamically loaded xsub be written for a library that
has global constructors that need to be initialized?
In my search for a solution, I came to believe that this was possible,
due to references to the CCsimple example in CookbookB. It gives a
recipe for building a new perl executable that handles C++ constructors
(which I've done). But how would perl know what constructors need to
be run, when the xsub (and hence the library) aren't loaded until the
perl interpreter starts running? Did I misunderstand the CCsimple
example? Note that my xsub code itself doesn't use c++, just the
library (and I only know that because it requires stdc++ to be linked
in).
I'm running HPUX 11, with a perl 5.8.6 that I built myself. I've tried
building perl and the xsub with the HP ANSI C compiler (we don't have
the c++ compiler), g++ (with ld for linking), and g++ (for both
compiling and linking, which of course eventually calls ld anyway).
They all seem to behave about the same.
Any suggestions/guidance? I can give more details about the xsub once
someone confirms that this is indeed possible.
Thanks.
6. Calling multiple perl subroutines from XS procedure
7. Loading external module from XS file?
8. updated xs question