syphilis, thanks that helped and .so are smaller ;)

spx2 thanks for good resource !

Unfortunately I encountered another problem, this time when I try to add perl compiler to C.

#!/usr/bin/perl use strict; use warnings; use Config; use Inline C => Config => BUILD_NOISY => 1, CCFLAGS => $Config{ccflags +}." -DDEBUG=1"; use Inline C => <<'END_C', NAME => 'Example', CLEAN_AFTER_BUILD =>0; static PerlInterpreter *my_perl; int main(int argc, char **argv) { char* command_line[] = {"", "-e", "print \"Hello from C!\\n\";"}; my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, NULL, 3, command_line, (char **)NULL); perl_run(my_perl); perl_destruct(my_perl); perl_free(my_perl); return 0; } int add( int a, int b ) { int result; result = a + b; return result; } int hello() { printf("Hello World\n"); } END_C sub message { print "Everything went well" } &message;

On windows this code fail:

"Dmake error code 129, while making \/patch_here/Example.dll" "A problem was encountered while attepting to compile and install your inline c code. The command that failed was dmake."

On Linux (CentOS 6) program compile successfully but problem appears in next step:

cc -o Example.o -c Example.c `perl -MExtUtils::Embed -e ccopts`

returns:

"Example.xs:4:20: error: INLINE.h: No such file or directory Example.c: In function âXS_main_mainâ: Example.c:55: warning: initialization makes pointer from integer without a cast"

Because Inline produce their own .o file I try to compile their .o file, again with no success:

cc -o Example Example.o `perl -MExtUtils::Embed -e ldopts`

return:

"Example.o: In function `XS_main_main': /home/admin/Embed/_Inline/build/Example/Example.c:55: undefined reference to `XS_unpack_charPtrPtr' collect2: ld returned 1 exit status"

I have no idea what is wrong here, looking for your help again monks ;)

Also, it is possible to implement full perl subroutine code to C code or just add pointer that refer to perl subroutine somewhere else ?

In reply to Re^2: Extending perl with C dynamic library. by Martin90
in thread Extending perl with C dynamic library. by Martin90

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.