Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

problem finding symbol in XS-created .so

by geoffleach (Beadle)
on May 24, 2010 at 17:12 UTC ( #841428=perlquestion: print w/replies, xml ) Need Help??
geoffleach has asked for the wisdom of the Perl Monks concerning the following question:

I'm attempting to diagnose a problem with Audio::TagLib, which is basically a collection of XS interfaces to the taglib library. The test script:
use Audio::TagLib; $id3 = Audio::TagLib::FileRef->new( 't.mp3' );
fails with the message:
Can't locate object method "new" via package "Audio::TagLib::FileRef" at

I've stepped through XSLoader, and it appears to be working correctly. The xs binary is installed: /usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/ auto/Audio/TagLib/ The .bs is there as well. It's empty. This appears to be correct. nm finds T XS_TagLib__FileRef_new.

I'm using 5.10.0. The dist uses ExtUtils::MakeMaker, and that's up to date.

Any suggestions on how to diagnose the problem?


Replies are listed 'Best First'.
Re: problem finding symbol in XS-created .so
by syphilis (Chancellor) on May 25, 2010 at 09:34 UTC
    $id3 = Audio::TagLib::FileRef->new( 't.mp3' );

    But fileref.xs defines functions (such as new) that are in package "TagLib::FileRef", *not* package "Audio::TagLib::FileRef". What happens if you recode that line to:
    $id3 = TagLib::FileRef->new( 't.mp3' );
      It also defines a fix for that
      sub xs_c { my $cmd = shift->SUPER::xs_c(@_); $cmd .= << 'END'; sed -i -e 's/newXSproto("TagLib/newXSproto("Audio::TagLib/g' $*.c sed -i -e 's/XS(boot_TagLib)/XS(boot_Audio__TagLib)/g' $*.c END return $cmd; }
        I'm sory, but I have no idea how this code relates to my problem.
      Can't locate TagLib/ in @INC ...
        No ... you still use Audio::TagLib; (Update: not use Audio::TagLib::FileRef as I had first written) but, instead of $id3 = Audio::TagLib::FileRef->new( 't.mp3' );
        you have $id3 = TagLib::FileRef->new( 't.mp3' );

        I don't really know whether that will work - I'd probably rather try changing the package name in fileref.xs to "Audio::TagLib::FileRef", but I don't know whether that will work, either :-)
        The module looks to me like a dog's breakfast

        I'll see if I can get anywhere with it on Windows and get back. In the meantime, just try anything you can think of.

Re: problem finding symbol in XS-created .so
by ikegami (Pope) on May 25, 2010 at 17:49 UTC

    In the .c file generated from the .xs files,

    (void)newXSproto_portable("TagLib::FileRef::new", XS_TagLib__FileRef_n +ew, file, ";$$$");

    should be

    (void)newXSproto_portable("Audio::TagLib::FileRef::new", XS_TagLib__Fi +leRef_new, file, ";$$$");

    This is because every MODULE= and PACKAGE= directive is wrong.

    Replace every instance of
    MODULE = TagLib
    MODULE = Audio::TagLib

    Replace every instance of
    PACKAGE = TagLib::...
    PACKAGE = Audio::TagLib::...

      The changes suggested have resolved the problem.

      Many thanks

Re: problem finding symbol in XS-created .so
by Anonymous Monk on May 25, 2010 at 07:06 UTC
    Any suggestions on how to diagnose the problem?

    Start from scratch, try with

    Something is going wrong with the XS generation, some file is not being included....all the test failures are about methods/symbols like new not being found.

    Seeing how ppport.h is version 3.06, and the latest available is Devel-PPPort-3.19_02, you should update that first and run perl ppport.h. This has a good chance of fixing the problem ( or revealing the real problem), since apparently Audio-TagLib works for the author with perl5.8.7 (which I infer from the authors ppport.h).

      Alas, no joy. No change in the behaviour.

      Both 1.50_01 (which I'm working with) and 1.43 have the same problem.


Re: problem finding symbol in XS-created .so
by chuckbutler (Prior) on May 24, 2010 at 21:57 UTC

    chmod permissions set for execute on the .so file? Just wondering.

    Good luck. -c

      -r-xr-xr-x 1 root root, alas. Thanks.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://841428]
Approved by lostjimmy
Front-paged by Argel
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-06-25 12:31 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.