Search code examples
perltimestamptime-hires

Using Time::HiRes in project after downloading from online: HiRes.so: undefined symbol: Perl_Gthr_key_ptr


I just started my hands on with Perl last week, because I was made to fix few things in our legacy code in production.

Situation is, there is perl 5.32.0 installed in our production and I can't change or install any packages in it.

In my code, I have to get time in milliseconds, which can be fetched using Time::HiRes module. But, I can't install it! So, I copied it in my project alongside my project file.

I downloaded Time-HiRes-1.9764.tar.gz from https://metacpan.org/pod/Time::HiRes, unzipped it and copied HiRes.pm under Time directory under my project.

I am getting this error:

/usr/local/bin/perl: symbol lookup error: /usr/local/bin/perl_5.6.1/lib/site_perl/5.6.1/i686-linux/auto/Time/HiRes/HiRes.so: undefined symbol: Perl_Gthr_key_ptr

Now, my questions is: What is the correct way of downloading HiRes.pm from online and copy in local project without any dependency? 2. List item


Solution

    1. Time::HiRes has been a core module since 5.7.3, i.e. it should be part of the Perl installation.

    2. The standard way of installing a Perl module is

    perl Makefile.PL
    make
    make test
    make install
    

    Some Perl modules aren't pure Perl, they also contain XS code that needs to be compiled, and Time::HiRes is one of them.