Similar Threads:
1.Using Module::Build to XS
Hi,
I have volunterred to maintain the LSF::Base and LSF::Batch modules on
CPAN , I am in the process of rewriting the module's Makefile.PL
(which uses the ExtUtils::MakeMaker) to use the Module::Build's
Build.PL process. Unfortunately I have not been very successful in
writing the Build.PL to do all the complies. Also I have not been able
to gather any information regarding the use of Module::Build to do XS
complies. Any inputs on where I can get this information would be
really helpful.
I have tried to write the Build.PL by using the following code snippet
but this was not able to create the shared object for Dynaloader to
load.
my $builder = Module::Build->new(
module_name => 'LSF::Base',
...
c_source => 'lib/',
include_dirs => [ $lsf_includedir ] ,
extra_linker_flags => $libs,
extra_compiler_flags => '-DPERL_POLLUTE',
create_makefile_pl => 'traditional'
);
Also any inputs on the Module::Build's equivalent of the below
Mafile.PL will be greatly appreciated.
WriteMakefile(
'NAME' => 'LSF::Base',
'VERSION_FROM' => 'Base.pm',
'LIBS' => [$libs ],
'DEFINE' => '-DPERL_POLLUTE',
'OBJECT' => '$(O_FILES)',
'INC' => "-I$lsf_includedir"
);
If this is a RTFM please do scream at me
Thanks
Raga
2.need template for an XS module using two or mor classes
Hi,
I created with the tool "h2xs" a template for a perl package called
"perlmsgque"
in this package I want to add a "MqS" and a "MqSException" class.
both class's should use an individual "*.xs" file called MqS.xs
and MqSException.xs.
I'm not able to get anything useful working with the current perl
documentation.
it seems that multiple packages into a single module is not
covered
one package per module is possible but multiple ....
error message I get: Base class package "MqS" is empty
even if MqS is filled ..
mfg
Andreas Otto
3.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 =========
4.Perl XS Module Build Error
Hi,
I am trying to rebuild our XS module using the newly installed Perl
5.8.4 with Dynamic Loading and 64-bit Integers enabled. During the XS
make process, I ran into the following error message. Can someone
explain to me what the error is about?
=========================================
LD_RUN_PATH="" g++ -shared -L/usr/local/lib HSDAdmin.o -o
blib/arch/auto/HSDAdmin/HSDAdmin.so ../../libhsd.a
/nfs/site/proj/vt/dev/hsd/vendor/freetds/0.62.3.bn1/lib/i386_linux24/libsybdb.a
/nfs/site/proj/vt/dev/hsd/vendor/freetds/0.62.3.bn1/lib/i386_linux24/libtds.a
/nfs/site/proj/vt/dev/hsd/vendor/boost/1.30.0/lib/i386_linux24/libboost_regex.a
../../libhsd.a(libhsd_a-HSDAdmin.o): In function
`HSDAdmin::getLUVal(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >&)':
/users/pptran/hsd/build/api/../../api/src/HSDAdmin.cpp:1118: multiple
definition of `HSDAdmin::getLUVal(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >&)'
HSDAdmin.o:/users/pptran/hsd/build/api/5.8.4/HSDAdmin/HSDAdmin.xs:70:
first defined here
/usr/intel/pkgs/gcc/3.1/bin/gld: Warning: size of symbol
`HSDAdmin::getLUVal(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >&)' changed from
2470 to 3226 in ../../libhsd.a(libhsd_a-HSDAdmin.o)
../../libhsd.a(libhsd_a-HSDAdmin.o): In function
`HSDAdmin::getSMParentValue(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >&)':
/users/pptran/hsd/build/api/../../api/src/HSDAdmin.cpp:1196: multiple
definition of `HSDAdmin::getSMParentValue(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >&)'
HSDAdmin.o:/users/pptran/hsd/build/api/5.8.4/HSDAdmin/HSDAdmin.xs:149:
first defined here
/usr/intel/pkgs/gcc/3.1/bin/gld: Warning: size of symbol
`HSDAdmin::getSMParentValue(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >&)' changed from 2470 to 3110 in
../../libhsd.a(libhsd_a-HSDAdmin.o)
collect2: ld returned 1 exit status
make[1]: *** [blib/arch/auto/HSDAdmin/HSDAdmin.so] Error 1
make[1]: Leaving directory
`/fs37/home.directory.1/pptran/hsd/build/api/5.8.4/HSDAdmin'
make: *** [all-local] Error 2
=============================================
Again, thanks in advance!
Phuong P Tran
5.Leaking memory in Perl XS Module
Hi Everyone,
I've been staring at this for hours now and I can't work out where I'm
leaking memory in a perl XS module I'm working on. Basically, I need to take
a tree of C structures:
typedef struct _SGraph {
char *name;
int size;
Graph list[];
} * Graph;
with a given head pointer and iterate through the graph and produce Perl
hashes which look like { name => "__root__", parent => undef, list = [ {
name => "child" }, parent => (ref to parent), list = ... } ]. I've got the
algorithm working a number of different ways but each one leaks memory. I'm
sending the current implementation along with this post, sorry for the long
post, this is the shortest example that demonstrates the issue.
Thanks,
Shaun
SV *RvFromRv_noinc(SV *ptRv)
{
return(newRV_noinc(SvRV(ptRv)));
}
HV *MakeHash(Graph ptGraph, SV *ptParent)
{
static HV *ptGraphStash = NULL;
HV *ptHash;
SV *ptSubHash;
AV *ptArray;
int i;
SV *ptResult;
if (ptGraphStash == NULL)
{
ptGraphStash = gv_stashpv("OGDL::Graph", 0);
if (!ptGraphStash)
ptGraphStash = (HV *) -1;
}
ptHash = (HV *) newHV();
if (!ptParent)
/* Storing &PL_sv_undef does not work */
hv_fetch(ptHash, "parent", 6, 1);
else
/* Store the reference to our parent */
hv_store(ptHash, "parent", 6, RvFromRv(ptParent), 0);
hv_store(ptHash, "name", 4, newSVpv(ptGraph->name, 0), 0);
ptResult = newRV_noinc((SV *) ptHash);
ptArray = newAV();
av_extend(ptArray, ptGraph->size);
for (i = 0; i < ptGraph->size; i++)
{
ptSubHash = MakeHash(ptGraph->nodes[i], ptResult);
av_push(ptArray, RvFromRv_noinc((SV *) ptSubHash));
}
hv_store(ptHash, "list", 4, newRV_noinc((SV *) ptArray), 0);
if (ptGraphStash && (ptGraphStash != (HV *) -1))
sv_bless(ptResult, ptGraphStash);
return(ptResult);
}
MODULE = OGDL::NativeParser PACKAGE = OGDL::NativeParser
SV *GraphFile(char *sFile)
{
SV *ptResult = NULL;
...
ptResult = MakeHash(*ptParser->g, NULL);
return(ptResult);
}
SV *
load(file)
char *file
PREINIT:
Graph ptGraph = NULL;
CODE:
/* Create perl hashes to return */
RETVAL = GraphFile(file);
OUTPUT:
RETVAL
6. building C DLL for calling from Perl using (*.XS)
7. Loading external module from XS file?
8. Modules for XS.