in reply to Re: use Inline CPP to call function in so file not working
in thread use Inline CPP to call function in so file not working

Hello Dave,

I'll suggest to update the POD: http://search.cpan.org/~davido/Inline-CPP-0.46/lib/Inline/CPP.pod

and
http://search.cpan.org/~sisyphus/Inline-0.53/C/C-Cookbook.pod#Exposing_Shared_Libraries

as I followed the instructions and examples there then end up with this question. I think other perl user will proberbly ask the same.

So far I've tried all sugestions to solve my problem, here is result:

Answers from syphilis and Anonymous Monk:


MYEXTLIB => '/full/path_to/libsay_hi.so'
instead of
LIBS=>"-l..."
: works fine!

Answers from Anonymous Monk:


link .so to .a,
and/or
using LIBS=>"-l+say_hi"
: not working...

Replies are listed 'Best First'.
Re^3: use Inline CPP to call function in so file not working
by syphilis (Archbishop) on Jan 10, 2014 at 09:03 UTC
    So far I've tried all sugestions to solve my problem ...

    I've just done some checking with Inline::C (not Inline::CPP), and it seems that you should also be able to link directly to the .so file using
    LIBS => '-L/path/to/so_file -lsay_hi',
    If that works with Inline::C (which it seems to), the same thing should probably be working with Inline::CPP.
    Of course, if libsay_hi.so is already in a location where the linker will find it, then the "-L/path/to/so_file" part should not be necessary.

    Could you double-check using "LIBS" with Inline::CPP ?

    I was initially of the view that EU::MM might do things that prevented you from linking directly to a shared object using the "LIBS" option - and that MYEXTLIBS would then be the *only* way of achieving this.
    But, like I say, this now seems to me to *not* be the case - with Inline::C and perl-5.18.0 at least.

    Cheers,
    Rob
Re^3: use Inline CPP to call function in so file not working
by Anonymous Monk on Jan 10, 2014 at 08:24 UTC

    as I followed the instructions and examples there then end up with this question. I think other perl user will proberbly ask the same.

    While I believe adding examples is good, I doubt other perl users will probably ask the same, because 90% of the time you're connecting to an existing libfoobar.a you're not creating your own libfoobar.a (which is regular c/c++ programming)

    Answers from Anonymous Monk:

    You're confused by PerlMonks codewrapping feature, I never suggested -l+say_hi , I suggested you create a libsay_hi.a through whatever means, so that when you say -lsay_hi and g++/gcc/ld looks for libsay_hi.a it can find one