I am trying to use Devel::NYTProf and have the following shell script:

#!/bin/tcsh -f setenv PERL5LIB "/home/user/perl_modules/lib/perl5/x86_64-linux" /usr/bin/perl -d:NYTProf factorial_recurse.pl 12

factorial_recurse.pl contains the following:

#!/usr/bin/perl use strict; sub factorial { return unless int($_[0]) == $_[0]; return 1 if $_[0] == 1; return $_[0] * factorial($_[0] - 1); } print factorial($ARGV[0]), "\n";

If I run the above, I receive the following error message:

Can't load '/home/user/perl_modules/lib/perl5/x86_64-linux/Devel/auto/ +Devel/NYTProf/NYTProf.so' for module Devel::NYTProf: /home/user/perl_ +modules/lib/perl5/x86_64-linux/Devel/auto/Devel/NYTProf/NYTProf.so: u +ndefined symbol: PL_stack_sp at /usr/share/perl5/XSLoader.pm line 68. at /home/user/perl_modules/lib/perl5/x86_64-linux/Devel/NYTProf/Core. +pm line 17. Compilation failed in require at /home/user/perl_modules/lib/perl5/x86 +_64-linux/Devel/NYTProf.pm line 26. Compilation failed in require. BEGIN failed--compilation aborted.

If I instead change /usr/bin/perl in the shell script to /tool/bin/perl, the script runs without errors. I found this fix when I searched for "undefined symbol: PL_stack_sp", but what exactly is going wrong here and why does using a different perl installation fix it? If anything I would expect the error case to be when the version of perl called in the shell script doesn't match the version specified in factorial_recurse.pl.
For reference, "/usr/bin/perl -v" is v5.16.3 and "/tool/bin/perl -v" is v5.12.2.


In reply to Devel::NYTProf: "undefined symbol: PL_stack_sp" error by Special_K

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.