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

problem finding symbol in XS-created .so

by geoffleach (Scribe)
on May 24, 2010 at 17:12 UTC ( [id://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 MP3test.pl

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/TagLib.so The .bs is there as well. It's empty. This appears to be correct. nm TagLib.so 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?

Thanks.

Replies are listed 'Best First'.
Re: problem finding symbol in XS-created .so
by syphilis (Archbishop) 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' );
    Cheers,
    Rob
      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/FileRef.pm 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.

        Cheers,
        Rob
Re: problem finding symbol in XS-created .so
by ikegami (Patriarch) 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
    with
    MODULE = Audio::TagLib

    Replace every instance of
    PACKAGE = TagLib::...
    with
    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 http://search.cpan.org/CPAN/authors/id/D/DO/DONGXU/Audio-TagLib-1.50_01.tar.gz.

    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.

      Thanks.

Re: problem finding symbol in XS-created .so
by chuckbutler (Monsignor) 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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://841428]
Approved by lostjimmy
Front-paged by Argel
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-29 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found