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

I have come for more wisdom, Monks!
I had posted a question about calling C programs using Inline. I had a response that you do not call programs, rather libraries. So I have come up with this example but I can't seem to execute it. These are my codes:
#include <stdio.h> /* define external functions */ extern void football(); extern void ok(); extern void big12(); int main() { printf("Inside main()\n"); /* use a function from each object file that is in the library */ football(); ok(); big12(); return 0; }
The code above is a C program that uses a library, libgin.a. The library has three other one-line print statement programs tied to it. Here's my code for the Inline process:
#!/usr/local/perl/5.6.1.4/bin/perl -w use ConsistentSet "1.0.2"; # This finds the library Inline use Inline C => DATA => LIBS => '-lgin'; first(); __END__ __C__ #include <stdio.h> #include "main.c" int first() { printf("Inside main()\n"); /* use a function from each object file that is in the library */ football(); ok(); big12(); return 0; }
What I have done is instead of calling main.c from my Inline code, I just rewrote the C code to call the functions in the library. I keep getting this error:
Inside main() ld.so.1: /usr/local/perl/5.6.1.4/bin/perl: fatal: relocation error: fi +le /SIMPLE/_Inline/lib/auto/first_pl_d0aa/first_pl_d0aa.so: symbol fo +otball: referenced symbol not found Killed

I need some desperate help!!!
With thanks, ginttu

Replies are listed 'Best First'.
Re: Still More Inline Problems
by Madams (Pilgrim) on Nov 21, 2002 at 22:24 UTC
    libgin.a is not an actual "library" nor is it "relocateable" in the sense that the library loader ld.so (which is a "relocateable library" itself) needs. I am not sure if Inline can use an "uncompiled/unlinked" library archive (eg: libxxx.a). It may be that Inline can use a nonrelocateable object (eg: libxxx.o) that it can "manually" link into. However I'm mostly sure what you need to do in this instance is actually compile libgin.a into a dynamic library (a .dll in MS land and a .so in un*x land). Then Inline should be able to access it.

    Good luck and I hope this was both informative and correct. Someone will hopefully speak up if I've borked it.
    _________________
    madams@scc.net
    (__) (\/) /-------\/ / | 666 || * ||----||
Re: Still More Inline Problems
by RMGir (Prior) on Nov 21, 2002 at 18:53 UTC
    What does "ldd /SIMPLE/_Inline/lib/auto/first_pl_d0aa/first_pl_d0aa.so" tell you?

    That should tell you what dynamic libs the .so expects to find and isn't...
    --
    Mike

      I realize that the shared library needs to find the function. I just don't understand where my code is going wrong...

      ginttu