in reply to Re: Extending perl with C dynamic library.
in thread Extending perl with C dynamic library.
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 ?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Extending perl with C dynamic library.
by BrowserUk (Patriarch) on Aug 19, 2013 at 12:55 UTC | |
by Martin90 (Sexton) on Aug 20, 2013 at 17:16 UTC | |
by syphilis (Archbishop) on Aug 20, 2013 at 23:51 UTC | |
by Martin90 (Sexton) on Aug 21, 2013 at 19:11 UTC | |
by syphilis (Archbishop) on Aug 21, 2013 at 22:30 UTC | |
| |
by BrowserUk (Patriarch) on Aug 20, 2013 at 19:04 UTC | |
by Martin90 (Sexton) on Aug 20, 2013 at 19:52 UTC | |
by BrowserUk (Patriarch) on Aug 20, 2013 at 20:04 UTC | |
| |
Re^3: Extending perl with C dynamic library.
by syphilis (Archbishop) on Aug 19, 2013 at 10:43 UTC |
In Section
Seekers of Perl Wisdom