Using Module::Build to XS

PERL

    Next

  • 1. encrypted passwd passed to ldap from Net::LDAP
    when using ldapmodify it is possible to add or replace a passwd in ldap while encrypting it. $DN replace:userPassword userPassword: {crypt}*LCK* Is there an accepted syntax in the NET::LDAP module to do this? $mesg = $ldap->modify( $entry, changes => [ add => [ cn => ['*LCK*']], add => [ userPassword => ????????? ], replace => [ icsStatus => 'inactive'], replace => [ mailUserStatus => 'inactive'] ] ); Thank you. Bard
  • 2. File::Find and selecting directories?
    Hello, [Apolgies as have already posted this in perl.misc but thought perhaps should have posted here...] The following code will put the addresses from the multiple versions of the nominal_3.htm files in a series of sub directories of d:/addresses into a file called addresses-file ... but I cannot see how to create a different file for each sub directory...How do I select each different sub directory using File::Find? Ideas please?! I Thanks Geoff use warnings; use strict; use File::Find; my $dir = 'd:/addresses'; find ( sub { if ($_ =~ /nomination_3.htm/) { print ("$_ \n"); open (IN, $_) or die ("Cannot open file $_ \n"); my $line = <IN>; while (defined($line = <IN>)) { if ($line =~ /<TD>(.*?)<\/TD>/i) { open (OUT, ">>d:/addresses/addresses-file"); print OUT ("$1 \n"); } } } }, $dir); close (OUT); close (IN);
  • 3. Perl Module SNMP Problem
    Hi, I have a problem in Perl SNMP module: Platform: Solaris 8, Perl 5.8.0 ucb-snmp: 4.2.3 (in /usr/local) perl module: SNMP-4.2.0 perl Makefile.PL -NET-SNMP-PATH=/usr/local make make test [all tests failed] Can't load '/usr/local/SNMP-4.2.0/blib/arch/auto/SNMP/SNMP.so' for module SNMP: ld.so.1: /usr/local/bin/perl5.8.0: fatal: relocation error: file /usr/local/SNMP-4.2.0/blib/arch/auto/SNMP/SNMP.so: symbol des_key_sched: referenced symbol not found at /usr/local/lib/perl5/5.8.0/sun4-solaris/DynaLoader.pm line 229. I found several people reporting similar errors but have not seen a solution. Please help! Thank you!! Guoben Li P.S. ldd /usr/local/SNMP-4.2.0/blib/arch/auto/SNMP/SNMP.so libcrypto.so.0.9.7 => /usr/local/ssl/lib/libcrypto.so.0.9.7 libkstat.so.1 => /usr/lib/libkstat.so.1 libc.so.1 => /usr/lib/libc.so.1 libsocket.so.1 => /usr/lib/libsocket.so.1 libnsl.so.1 => /usr/lib/libnsl.so.1 libdl.so.1 => /usr/lib/libdl.so.1 libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 libmp.so.2 => /usr/lib/libmp.so.2 /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
  • 4. DBD::DB2 Numeric value out of range.
    Hi Folks, I am doing DB2 access via perl DBI but have trouble while fetching value which is negative REAL: i.e. SELECT X FROM TABLE FETCH FIRST ROWS ONLY; This should return "-1". But instead I have this error message and no data retrieved: [error] DBD::DB2::st fetchrow_array failed: [IBM][CLI Driver] CLI0111E Numeric value out of range. SQLSTATE=22003 Could you please advice? Many thanks in advance, Bing

Using Module::Build to XS

Postby Raga » Thu, 20 Dec 2007 06:50:53 GMT

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

Similar Threads:

1.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

2.building C DLL for calling from Perl using (*.XS)

Have anyone tried hooking perl to external C libraries?  I am trying
to port some code in C  into a module (ie. DLL) which can then be
called from Perl.
I did the usual stuffs with h2xs to generate the Mytest.xs/Mytest.pm
and support environment.

As a Test wanted to see how Mytest.xs file works so I proceed to
modify.  I wanted first to see that it can pull in the headers ok.
so I added to Mytest.xs
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#ifdef __cplusplus
}
#endif
---------------------------------------------------------------
Then of course the perl Makefile.pl to generate *.c etc
Then tried to use MSVC6 to compile it, everything is ok except for
malloc.h
Here is what came out from NMAKE

E:\var\h2xs\Mytest>nmake

Microsoft (R) Program Maintenance Utility   Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

cp Mytest.pm blib\lib\Mytest.pm
cp mytest.pl blib\lib\mytest.pl
        C:\Perl\bin\perl.exe -IC:\Perl\lib -IC:\Perl\lib
C:\Perl\lib\ExtUtils/xs
ubpp  -typemap C:\Perl\lib\ExtUtils\typemap Mytest.xs > Mytest.xsc &&
C:\Perl\bi
n\perl.exe -IC:\Perl\lib -IC:\Perl\lib -MExtUtils::Command -e mv
Mytest.xsc Myte
st.c
Please specify prototyping behavior for Mytest.xs (see perlxs manual)
        cl -c  -nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE
-DNO_STRICT -DHAV
E_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DPERL_MSVCRT_READFIX -
O1 -MD -Zi -DNDEBUG    -DVERSION=\"0.01\"  -DXS_VERSION=\"0.01\" 
-IC:\Perl\lib\
CORE  Mytest.c
Mytest.c
C:\VC\VC98\INCLUDE\malloc.h(106) : error C2059: syntax error : '('
C:\VC\VC98\INCLUDE\malloc.h(107) : error C2059: syntax error : '('
C:\VC\VC98\INCLUDE\malloc.h(108) : error C2059: syntax error : '('
NMAKE : fatal error U1077: 'C:\WINNT\system32\cmd.exe' : return code
'0x2'
Stop.

-------------------------------------------------------------------------------
I opened up malloc.h in an editor and this is what I see at those 3
lines (106,107,108)

_CRTIMP void    __cdecl free(void *);
_CRTIMP void *  __cdecl malloc(size_t);
_CRTIMP void *  __cdecl realloc(void *, size_t);
-------------------------------------------------------------------------------


Surely someone musta have had to use malloc.h before for whatever
reason.  I have no idea how to fix it.  Can someone help??

3.Perl Module using XS

Hello "XS  Gurus":
I am trying to develop a perl extension using XS that would execute a DB2's 
'.sqc' generated c executable.( equivalent of Oracle's pro*c generated 
executable). The 'C' executable executes fine by itself.  I am having a hard 
time getting the perl module work.
I added in the '.xs' file the Xsubb for the function that is declared in the 
'C' program.
In the Makefile.PL, I added the object files generated from the 'C' program 
and also the path where the object file can be fouind.
Still, the make process does not succeed in building the 'C' function into 
the Perl module.
Could anyone show pointers as to what i am missing
thanks
Rajan


use 5.008008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
        NAME              => 'RajanT',
        VERSION_FROM      => 'lib/RajanT.pm', # finds $VERSION
        PREREQ_PM         => {}, # e.g., Module::Name => 1.1
        ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
        (ABSTRACT_FROM  => 'lib/RajanT.pm', # retrieve abstract from module
        AUTHOR         => 'Abishek Rajan < XXXX@XXXXX.COM >') : ()),
        LIBS              => [''], # e.g., '-lm'
        DEFINE            => '', # e.g., '-DHAVE_SOMETHING'
        INC               => '-I. -I/home/db2inst2', # e.g., 
'-I. -I/usr/include/other'
        MYEXTLIB => 'rlib/libmylib$(LIB_EXT)',
                # Un-comment this if you add C files to link with later:
                OBJECT            => '$(example2.o)', # link all the C files 
too
);
if  (eval {require ExtUtils::Constant; 1}) {
# If you edit these definitions to change the constants used by this module,
# you will need to use the generated const-c.inc and const-xs.inc
# files to replace their "fallback" counterparts before distributing your
# changes.
my @names = (qw(TESTVAL));
ExtUtils::Constant::WriteConstants(
NAME         => 'RajanT',
NAMES        => \@names,
DEFAULT_TYPE => 'IV',
C_FILE       => 'const-c.inc',
XS_FILE      => 'const-xs.inc',
);
}
else {
use File::Copy;
use File::Spec;
foreach my $file ('const-c.inc', 'const-xs.inc') {
my $fallback = File::Spec->catfile('fallback', $file);
copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
}
}

sub MY::postamble {
'
$(MYEXTLIB): rlib/Makefile
        cd rlib && $(MAKE) $(PASSTHRU)
';



4.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



5.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 =========

6. Same problem building several modules on XP using Visual Studio .NET

7. List of sample Build::Module Build.PL



Return to PERL

 

Who is online

Users browsing this forum: No registered users and 63 guest