in reply to Re^5: Inline::C produces compilation errors
in thread Inline::C produces compilation errors

More Info:
I reinstalled version-0.74 and Parse-RecDescent-v1.95.1, both of whom are prerequesistes to installing Inline::C. The make test ended with "Failed 5/6 test scripts, 16.67% okay. 8/11 subtests failed, 27.27% okay." as it had before.
When I tried running the original program I get the same result.So I tried the following minimalist program:
my $kk = kk(); print "perl kk=$kk\n"; use Inline C => <<'END_OF_C_CODE'; #include <stdio.h> #include <stdlib.h> #include <string.h> int kk () { printf("Hello!\n"); return(0); } END_OF_C_CODE
And I got the following output:
Hello! perl kk=0
So I can compile something, I then kept adding the lines I needed one at a time until I got to this:
my $kk = kk(); print "perl kk=$kk\n"; use Inline C => Config => LIBS => '-L/HASP/perltestP -llibhasp_linux.a +'; use Inline C => <<'END_OF_C_CODE'; #include <stdio.h> #include <stdlib.h> #include <string.h> #include <hasp_hl.h> #include <hasp_vcode.h> int kk () { hasp_status_t status; hasp_handle_t handle; int i; char filename[] = "prg"; printf("Hello!\n"); status = hasp_login(HASP_PROGNUM_DEFAULT_FID, (hasp_vendor_code_t *)vendor_code, &handle); // switch (status) { // case HASP_STATUS_OK: // printf("OK\n"); // hasp_logout(handle); // return(1); // break; // default: // printf("BAD\n"); return(0); } END_OF_C_CODE
Which broke complaining that :perl: symbol lookup error: /HASP/perltestP/_Inline/lib/auto/c2_pl_4339/c2_pl_4339.so: undefined symbol: hasp_login".
 
However, if I approach this from the C side as follows, it recolves hasp_login without a problem.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <hasp_hl.h> #include <hasp_vcode.h> int kk () { hasp_status_t status; hasp_handle_t handle; int i; printf("start : "); status = hasp_login(HASP_PROGNUM_DEFAULT_FID, (hasp_vendor_code_t *)vendor_code, &handle); switch (status) { case HASP_STATUS_OK: printf("OK\n"); hasp_logout(handle); return(1); break; default: printf("BAD\n"); return(0); } } int main(void) { int result; result = kk(); printf("result was %d\n",result); }
This would indicate that Inline::C is unable to resolve extenal references that are not from itself ??? I think it all relates the the tests that are being failed on the "make test" of the Inlince::C installation. I've googled and I have checked the bug reports in cpan.org. Nothing really looks like this. Should I report it as a bug to "INGY" on cpan.org's site?

Replies are listed 'Best First'.
Re^7: Inline::C produces compilation errors
by syphilis (Archbishop) on Nov 24, 2007 at 22:29 UTC
    use Inline C => Config => LIBS => '-L/HASP/perltestP -llibhasp_linux.a';

    I think that's wrong, unless the library is called something like libhasp_linux.a.a. Or is the linker smart enough to know that the '.a' should be dropped ? I would change it to:
    use Inline C => Config => LIBS => '-L/HASP/perltestP -llibhasp_linux', BUILD_NOISY => 1;
    and check the output for any messages that tell you that no library was found for -llibhasp_linux. When you build the C program do you provide an -llibhasp_linux.a argument on the command line (or is it simply -llibhasp_linux ) ? I would expect that whatever argument works on the command line should also work for the 'LIBS' config option.

    Note: The BUILD_NOISY option means that you'll see any warnings that are emitted during the build process. Without it, relevant warnings often don't appear.

    Cheers,
    Rob