in reply to Re: Inline CPP
in thread Inline CPP

Hi Rob, You are most helpfull and I really appreciate your help. I did as you said : 1. I "make clean" to erase all the compiled objects. 2. I added your BUILD_NOISY flag. 3. I addid a -L directive to the loaction of that lib in a different style (all the directive together seems to work better than separately - I don't know why):
use Inline (CPP => 'DATA', LIBS => '-L/users/nirf/perlTrials/cNewModule/lib -lmai +n -L/usr/lib -lstdc++', INC => '-I/users/nirf/perlTrials/inlineExample', WARNINGS => 0, NAME => 'PM_wed', VERSION => '0.01', BUILD_NOISY => 1, );
4.I tried to remove the warnings regarding iostream.h by adding to the parameters the line " ENABLE => STD_IOSTREAM," :
use Inline (CPP => 'DATA', LIBS => '-L/users/nirf/perlTrials/cNewModule/lib -lmai +n -L/usr/lib -lstdc++', INC => '-I/users/nirf/perlTrials/inlineExample', WARNINGS => 0, NAME => 'PM_wed', VERSION => '0.01', BUILD_NOISY => 1, ENABLE => STD_IOSTREAM, );
but it didn't work. do you know why? 5.The new error I get now is as follows. It doesn't find that library (although it says so only in the test phase):
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib/lib', 'blib/arch')" t/*.t t/1....ok 1/1Had problems bootstrapping Inline module 'PM_wed' Can't load '/users/nirf/perlTrials/PM_wed/blib/arch/auto/PM_wed/PM_wed +.so' for module PM_wed: libmain.so: cannot open shared object file: N +o such file or directory at /usr/lib/perl5/5.8.5/i386-linux-thread-mu +lti/DynaLoader.pm line 230, <DATA> line 1. at /usr/lib/perl5/vendor_perl/5.8.5/Inline.pm line 500 at t/1.t line 0 INIT failed--call queue aborted, <DATA> line 1. # Looks like your test died just after 1. t/1....dubious Test returned status 255 (wstat 65280, 0xff00) after all the subtests completed successfully Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t/1.t 255 65280 1 0 0.00% ?? Failed 1/1 test scripts, 0.00% okay. 0/1 subtests failed, 100.00% okay +. make: *** [test_dynamic] Error 2
By the way,the messages I get in the "make" phase seems ok (there is no indication to the error that follows at the next "test" phase) :
cp PM_wed.pm blib/lib/PM_wed.pm /usr/bin/perl -Mblib -MInline=NOISY,_INSTALL_ -MPM_wed -e1 0.01 blib/a +rch Starting Build Prepocess Stage Finished Build Prepocess Stage Starting Build Parse Stage Finished Build Parse Stage Starting Build Glue 1 Stage Finished Build Glue 1 Stage Starting Build Glue 2 Stage Finished Build Glue 2 Stage Starting Build Glue 3 Stage Finished Build Glue 3 Stage Starting Build Compile Stage Starting "perl Makefile.PL" Stage WARNING: CC is not a known parameter. Writing Makefile for PM_wed Finished "perl Makefile.PL" Stage Starting "make" Stage make[1]: Entering directory `/users/nirf/perlTrials/PM_wed/_Inline/bui +ld/PM_wed' /usr/bin/perl /usr/lib/perl5/5.8.0/ExtUtils/xsubpp -typemap /usr/lib/ +perl5/5.8.0/ExtUtils/typemap PM_wed.xs > PM_wed.xsc && mv PM_wed.xs +c PM_wed.c g++ -c -I/users/nirf/perlTrials/PM_wed -I/users/nirf/perlTrials/inlin +eExample -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING - +fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_ +OFFSET_BITS=64 -I/usr/include/gdbm -O2 -march=i386 -mcpu=i686 -g -D +VERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/usr/lib/perl5/5.8.0/ +i386-linux-thread-multi/CORE" PM_wed.c In file included from /usr/include/c++/3.2.2/backward/iostream.h:31, from PM_wed.xs:2: /usr/include/c++/3.2.2/backward/backward_warning.h:32:2: warning: #war +ning 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 f +or the <X.h> header for C++ includes, or <sstream> instead of the dep +recated header <strstream.h>. To disable this warning use -Wno-deprec +ated. Running Mkbootstrap for PM_wed () chmod 644 PM_wed.bs rm -f blib/arch/auto/PM_wed/PM_wed.so LD_RUN_PATH="/usr/lib:/users/nirf/perlTrials/cNewModule/lib" gcc -sha +red -L/usr/local/lib PM_wed.o -o blib/arch/auto/PM_wed/PM_wed.so - +lstdc++ -L/users/nirf/perlTrials/cNewModule/lib -lmain -L/usr/lib -ls +tdc++ chmod 755 blib/arch/auto/PM_wed/PM_wed.so cp PM_wed.bs blib/arch/auto/PM_wed/PM_wed.bs chmod 644 blib/arch/auto/PM_wed/PM_wed.bs make[1]: Leaving directory `/users/nirf/perlTrials/PM_wed/_Inline/buil +d/PM_wed' Finished "make" Stage Starting "make install" Stage make[1]: Entering directory `/users/nirf/perlTrials/PM_wed/_Inline/bui +ld/PM_wed' Installing /users/nirf/perlTrials/PM_wed/blib/arch/auto/PM_wed/PM_wed. +so Installing /users/nirf/perlTrials/PM_wed/blib/arch/auto/PM_wed/PM_wed. +bs Files found in blib/arch: installing files in blib/lib into architectu +re dependent library tree Writing /users/nirf/perlTrials/PM_wed/blib/arch/auto/PM_wed/.packlist make[1]: Leaving directory `/users/nirf/perlTrials/PM_wed/_Inline/buil +d/PM_wed' Finished "make install" Stage Starting Cleaning Up Stage Finished Cleaning Up Stage Finished Build Compile Stage
Thanks, Nir

Replies are listed 'Best First'.
Re^3: Inline CPP
by nirf1 (Novice) on May 21, 2008 at 10:07 UTC
    Hi Rob, I managed to solve the linkage problem. I still have the problem with ENABLE => STD_IOSTREAM - I still need help in that aspect). Apparently in the test phase The LD_LIBRARY_PATH should have the path to the libmain.so (my external libraries). and it is not sufficient to have that path in the pm file (in the LIBS -L option in
    use Inline (CPP => 'DATA', LIBS => '-L/users/nirf/perlTrials/cNewModule/lib -lmai +n -L/usr/lib -lstdc++', INC => '-I/users/nirf/perlTrials/inlineExample', WARNINGS => 0, NAME => 'PM_wed', VERSION => '0.01', BUILD_NOISY => 1, );
    ) Thanks, Nir
      Hi All, I am trying to call from perl script to a function that is defined inside another perl module. That module is an Inline::CPP, and the function I call to is a cpp function. The function gets a pointer to an int and needs to fill it:
      int add_nir(int x, int y, int* ref_int )
      I am trying to call that function with :
      my $test; add_nir(1,4,\$test);
      but I get the following error :
      Can't locate auto/PM_wed/add_nir.al in @INC (@INC contains: ...
      any other fuction (that doesn't receives a pointer) in the cpp part that is called from the perl script is propogated and executed correctly. Can someone please tell me what I did wrong? Thanks, Nir
        It may just be that \$test is not a reference to an int. In any case, I'd be rewriting add_nir(). I think the following does what you want:
        use warnings; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'EOC'; void add_nir(int x, int y, SV * ref_int) { sv_setiv(ref_int, x + y); } EOC my $test; add_nir(1, 4, $test); print $test, "\n"; # prints "5"
        I also seem to recall that there can be problems when one Inline function tries to access an Inline'd function in a module - but I'm not sure of the details. It's not all that difficult to remove the Inline dependency from a module (thereby making it the same as any other XS module). <plug>InlineX::C2XS and InlineX::CPP2XS can help with that </plug>.

        Cheers,
        Rob