I have a collection of perl modules that were installed locally (/home/user_foo/perl_modules/lib/perl5) using cpanm (cpanm -L$PWD <module_name>). This particular machine is running RHEL7 and has the following 2 perl versions installed:

/tool/bin/perl (v5.12.2) /usr/bin/perl (v5.16.3)

Scripts created on this machine start with #!/tool/bin/perl and have use lib '/home/user_foo/perl_modules/lib/perl5' to access the locally-installed modules. Note /home/user_foo/perl_modules/lib/perl5 is on a network and accessible to all machines. If I try to run those scripts on a different machine running RHEL8, I receive the following error:

/tool/bin/perl: symbol lookup error: /home/user_foo/perl_modules/lib/p +erl5/x86_64-linux/auto/List/Util/Util.so: undefined symbol: Perl_gv_i +nit

This RHEL8 machine has the following versions of perl installed:

/tool/bin/perl (v5.20.0) /usr/bin/perl (v5.26.3)

Based on some searching it seems the error is related to a mismatch between the version of perl being run vs the version of perl used to originally install the modules. If I create a new local perl module installation directory on the RHEL8 machine:

/new_location/perl_modules/5.20/lib/perl5

then reinstall the modules using cpanm (cpanm -L$PWD <module_name>), I notice the following things:

1. If I change my scripts to have use lib '/new_location/perl_modules/5.20/lib/perl5' but keep the #!/tool/bin/perl, the scripts work fine.
2. If I change my scripts to have use lib '/new_location/perl_modules/5.20/lib/perl5' and also change #!/tool/bin/perl to #!/usr/bin/perl, the scripts still work fine even though the perl version is now different.
3. The /new_location/perl_modules/5.20/lib/perl5 has a 5.26.3/x86_64-linux-thread-multi subdirectory that is empty

What exactly is causing the original error above? I suspect it is some sort of mismatch issue between the version of perl used to install the modules vs the version being run, but that leads to the following questions:

1. How do I specify which version of perl is being used when I install a module using cpanm?
2. Why do the new modules I installed to /new_location/perl_modules/5.20/lib/perl5 work for both /tool/bin/perl (v5.20.0) and /usr/bin/perl (v5.26.3) if module installations are version-dependent? Or am I misunderstanding the real issue here?

In reply to "symbol lookup error" message help 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.