in reply to Re: "symbol lookup error" message help
in thread "symbol lookup error" message help

> 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.

  • Comment on Re^2: "symbol lookup error" message help

Replies are listed 'Best First'.
Re^3: "symbol lookup error" message help
by hv (Prior) on Jan 28, 2023 at 23:49 UTC

    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.

Re^3: "symbol lookup error" message help
by choroba (Cardinal) on Jan 28, 2023 at 18:11 UTC
    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]