Hi perl monks,

I am very new to Perl and I am facing a difficulty with pm. I will appreciate any help.

I used
h2xs -AXc -n NewModule
in order to create my new pm that uses inline cpp. I edited MakeFile.pl and inserted my code. Than I did the following steps:
1.perl MakeFile.pl
2.make
3.make test

the test failed !!!!!!!! Can someone tell me please what I did wrong ?

by the way : I installed all the modules for the inline cpp. When I run a simple pl program (*.pl file) with similiar cpp code, everything works fine. The error :
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib/lib', 'blib/arch')" t/*.t t/NewModule....Warning: No Inline C++ functions or classes bound to Pe +rl Check your C++ for Inline compatibility. # Failed test (t/NewModule.t at line 9) # Tried to use 'NewModule'. # Error: make[1]: Entering directory `/users/nirf/perlTrials/NewM +odule/_Inline/build/NewModule_b1a3' # /usr/bin/perl /usr/lib/perl5/5.8.5/ExtUtils/xsubpp -typemap /usr/li +b/perl5/5.8.5/ExtUtils/typemap NewModule_b1a3.xs > NewModule_b1a3.x +sc && mv NewModule_b1a3.xsc NewModule_b1a3.c # g++ -c -I/users/nirf/perlTrials/NewModule/t -D_REENTRANT -D_GNU_SOU +RCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LA +RGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pip +e -m32 -march=i386 -mtune=pentium4 -DVERSION=\"0.00\" -DXS_VERSION= +\"0.00\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE" + NewModule_b1a3.c # In file included from /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../ +../include/c++/3.4.6/backward/iostream.h:31, # from NewModule_b1a3.xs:2: # /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/b +ackward/backward_warning.h:32:2: warning: #warning This file includes + at least one deprecated or antiquated header. Please consider using +one of the 32 headers found in section 17.4.1.2 of the C++ standard. +Examples include substituting the <X> header for the <X.h> header for + C++ includes, or <iostream> instead of the deprecated header <iostre +am.h>. To disable this warning use -Wno-deprecated. # NewModule_b1a3.xs:15: error: expected constructor, destructor, or ty +pe conversion before '=' token # make[1]: *** [NewModule_b1a3.o] Error 1 # make[1]: Leaving directory `/users/nirf/perlTrials/NewModule/_Inline +/build/NewModule_b1a3' # # A problem was encountered while attempting to compile and install yo +ur Inline # CPP code. The command that failed was: # make > out.make 2>&1 # # The build directory was: # /users/nirf/perlTrials/NewModule/_Inline/build/NewModule_b1a3 # # To debug the problem, cd to the build directory, and inspect the out +put files. # # at /users/nirf/perlTrials/NewModule/blib/lib/NewModule.pm line 11 # BEGIN failed--compilation aborted at /users/nirf/perlTrials/NewModul +e/blib/lib/NewModule.pm line 11. # Compilation failed in require at (eval 1) line 2. # Looks like you failed 1 tests of 1. t/NewModule....dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 1 Failed 1/1 tests, 0.00% okay Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t/NewModule.t 1 256 1 1 100.00% 1 Failed 1/1 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay. make: *** [test_dynamic] Error 2 &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
The NewModule.pm is :

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& package NewModule; use 5.008005; use strict; use warnings; use lib '/usr/lib/perl5/vendor_perl/5.8.0'; use lib '/users/nirf/perlTrials/cpanModulesInstallation/lib/perl5/site +_perl/5.8.0'; use lib '/users/nirf/perlTrials/cpanModulesInstallationInline/lib/perl +5/site_perl/5.8.5'; use Inline CPP => Config => INC => '-l/users/nirf/perlTrials/inlineExa +mple'; use Inline CPP => Config => MYEXTLIB => '/users/nirf/perlTrials/inline +Example/libmain.so'; use Inline CPP => 'END'; use Inline CPP => Config => ENABLE => STD_IOSTREAM; require Exporter; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not expo +rt # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use NewModule ':all'; # If you do not need this, moving things directly into @EXPORT or @EXP +ORT_OK # will save memory. our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( ); our $VERSION = '0.01'; __END__ __CPP__ + #include "main.h" char GlobalArr[13] = {'G','l','o','b','a','l',' ','a','r','r','a',' +y','\0',}; MyClass myGlobalInstance(GlobalArr) ; int add(int x, int y) { char arr[7]={'i','n',' ','a','d','d','\0'}; MyClass mc(arr); myGlobalInstance.wow(); return x + y; } 1; # Below is stub documentation for your module. You'd better edit it! =head1 NAME NewModule - Perl extension for blah blah blah =head1 SYNOPSIS use NewModule; blah blah blah =head1 DESCRIPTION Stub documentation for NewModule, created by h2xs. It looks like the author of the extension was negligent enough to leave the stub unedited. Blah blah blah. =head2 EXPORT None by default. =head1 SEE ALSO Mention other useful documentation such as the documentation of related modules or operating system documentation (such as man pages in UNIX), or any relevant external documentation such as RFCs or standards. If you have a mailing list set up for your module, mention it here. If you have a web site set up for your module, mention it here. =head1 AUTHOR Nir Frenkel, E<lt>nirf@localdomainE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2008 by Nir Frenkel This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. =cut &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Thanks, Nir

In reply to inline in a perl module by nirf1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.