On Feb 26, 2007, at 3:50 PM, Adam Ginsburg wrote:

Doug - Thanks, that looks very useful.  I'll certainly use it to test
out my code, it seems like the sensible way to do that.  Going back to
those math libraries, though... is there any way to include them while
using inline?

Thanks,
Adam

Adam,

My knowledge is rather rusty, but you should be able to use the "LIBS" option of Inline to do this - a la

http://search.cpan.org/dist/Inline/C/C.pod#LIBS

Aha, 'perldoc inline::pdlpp' has the following example (for the rather-more involved case of linking against the poidev routine from the Numerical Recipes library/code, but it does show you how to set up the LIBS part):

use PDL; # this must be called before (!) 'use Inline Pdlpp' calls

          use Inline Pdlpp => Config =>
            INC => "-I$ENV{HOME}/include",
            LIBS => "-L$ENV{HOME}/lib -lnr -lm",
            # code to be included in the generated XS
            AUTO_INCLUDE => <<'EOINC',
          #include <math.h>
          #include "nr.h"    /* for poidev */
          #include "nrutil.h"  /* for err_handler */

          static void nr_barf(char *err_txt)
          {
            fprintf(stderr,"Now calling croak...\n");
            croak("NR runtime error: %s",err_txt);
          }
          EOINC
# install our error handler when loading the Inline::Pdlpp code
          BOOT => 'set_nr_err_handler(nr_barf);';

use Inline Pdlpp; # the actual code is in the __Pdlpp__ block below

          $a = zeroes(10) + 30;;
          print $a->poidev(5),"\n";

          __DATA__

          __Pdlpp__

          pp_def('poidev',
                  Pars => 'xm(); [o] pd()',
                  GenericTypes => [L,F,D],
                  OtherPars => 'long idum',
Code => '$pd() = poidev((float) $xm(), &$COMP(idum));',
          );


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to