Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: "symbol lookup error" message help

by choroba (Cardinal)
on Jan 20, 2023 at 21:09 UTC ( [id://11149733]=note: print w/replies, xml ) Need Help??


in reply to "symbol lookup error" message help

Pure Perl modules can work in different versions of Perl. XS modules need to be compiled when installed, using the same compiler as the Perl they are being installed to.

cpanm (or any other client) installs the modules where you tell it to do it. It will use the perl you installed it for, i.e. the perl that runs it.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: "symbol lookup error" message help
by Special_K (Monk) on Jan 23, 2023 at 17:40 UTC
    > XS modules need to be compiled when installed, using the same compiler as the Perl they are being installed to.

    Can you please elaborate on this? I'm not familiar with XS, but a brief search turns up the "xsubpp" utility, which is apparently used to compile Perl XS code into C code. If I run xsubpp -v on each of the two machines, I receive the following output:

    RHEL7: xsubpp version 2.21 RHEL8: xsubpp version 3.24

    These xsubpp versions seem completely separate from any version of perl installed on the system. Are you saying that when an XS module such as List::Util is installed, whatever version of xsubpp happens to be installed on the system is used to compile the C code and from then on, only machines with that same version of xsubpp installed can use the module?

      Don't care about xsubpp. When you upgrade Perl, simply reinstall all the modules for the new version.

      Alternatively, use PerlBrew to keep several Perl versions. Each version needs its own set of modules (again, in fact, only XS modules need to be different, but if you don't know which these are, just install all of them for each version).

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

        Let's say I have a script that starts as follows:



        #!/usr/bin/perl use strict; use warnings; use lib '/home/foo/perl_modules/5.32.1/lib/perl5' use List::MoreUtils qw(uniq);


        Assume on one machine /usr/bin/perl points to perl version 5.32.1. Also assume the List::MoreUtils module is installed in /home/foo/perl_modules/5.32.1/lib/perl5 using perl 5.32.1.

        Now assume on another machine /usr/bin/perl points to perl 5.26.3. Also assume the List::MoreUtils module is installed in /home/foo/perl_modules/5.26.3/lib/perl5 using perl 5.26.3.

        Is there a way to manage this such that the script can be run on both machines, each with their respective perl versions, without having to make 2 copies of the script, one for each module path?

        Given a directory where perl modules are already installed (ex: /home/user_foo/perl_modules/lib/perl5 from my original message), how do I determine what version of perl was used to install them?
Re^2: "symbol lookup error" message help
by Special_K (Monk) on Jan 28, 2023 at 17:43 UTC

    > XS modules need to be compiled when installed, using the same compiler as the Perl they are being installed to.

    What exactly is being compiled into what in this context, and by what? Is it C/C++ -> assembly? Perl -> something else? Is xsubpp is the compiler in the context of the quoted message? I'm just trying to understand why the same version of perl is required to run modules that use XS as was used to install them.

      The source code in XS is being compiled into the machine code. See perlxs for details, but it's rather advanced, so maybe start with Wikipedia that has a nice basic introduction.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      You could roughly define XS as a macro language - it is only a little bit more than pure C with a bunch of predefined macros. It is preprocessed by xsubpp into C, then compiled with the appropriate C compiler into an object file (i.e. machine code).

      It needs the same version of perl mainly because it deals with a bunch of perl's internal data structures - when compiled, that bakes in knowledge of the size of those structures, and the offset of various elements within them. It also bakes in knowledge of the signature of the various perl internal functions it may call, along with compiler-specific calling conventions.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11149733]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found