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