llancet has asked for the wisdom of the Perl Monks concerning the following question:

Ok, I got the key. The module library should be located at auto/FooBar/FooBar.so instead of auto/FooBar.so...

============================================

Hi monks!

I'm writing a module with XS, which is a wrapper for another library. I made a simple test on my module:

1. link FooBar.pm to current directory,

2. link compiled FooBar.so to ./auto/,

3. then run perl -MFooBar, and it cries:

Can't find 'boot_FooBar' symbol in /usr/local/lib/libFooBar.so at - line 0.

This is strange, as boot_FooBar is compiled in the perl wrapper library, so it should not be searched in the original library.

I'm sure boot_FooBar is inside auto/FooBar.so, by using readelf -s:

46: 00000000000048a4  1049 FUNC    GLOBAL DEFAULT   11 boot_FooBar

In addition, I did not use any perl helper modules (like Module::Build or ExtUtils::MakeMaker) to build my module. I did everything manually.

Replies are listed 'Best First'.
Re: XS module cannot find boot_FooBar symbol
by tobyink (Canon) on Mar 04, 2014 at 09:15 UTC

    Why on earth are you not using EUMM?! Even idiots like me can write XS code with EUMM!!

    Asking for help getting XS code to work without EUMM is like asking us for advice on how to row across the Atlantic without a boat.

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
      I don't like the default behaviors by EUMM. I write a CMake wrapper. Nevertheless, re-inventing the wheel is fun (^_^)
Re: XS module cannot find boot_FooBar symbol
by davido (Cardinal) on Mar 04, 2014 at 15:53 UTC

    If you want to reinvent why not at least gain the benefit of learning from prior art? Start with EU::MM, get it working there, browse the files it creates and uses, discover what typemaps are needed, and then replicate that outcome yourself but with the changes implemented that you prefer.


    Dave

      Yes, I've read some codes of EUMM. Actually, I also read some code of M::B, M::B::X, M::I. I noticed that they are heavily relied on the the Config module.

      Now my CMake XS dev wrapper works for a minimum test module, but don't work if the module relies on another library. That is the origin I ask the question here.

Re: XS module cannot find boot_FooBar symbol
by Anonymous Monk on Mar 04, 2014 at 08:42 UTC
    you can't be serious
Re: XS module cannot find boot_FooBar symbol
by bulk88 (Priest) on Mar 05, 2014 at 05:02 UTC
    In 1 part of your post your error message says "libFooBar.so", in the other you call the file FooBar.so. I'm not a POSIX person, but get your filenames straight.

      These are two files. The libFooBar.so is the original library, and the FooBar.so is the library for the perl wrapper module.

      I've solved this issue by placing FooBar.so on the correct location.