in reply to Re^5: Extending perl with C dynamic library.
in thread Extending perl with C dynamic library.
I tried another way which simplify the fact of implement some code to C and then use this code in perl by:
My Inline code (compiles and works well):
#! perl -slw use strict; 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; #include <stdio.h> #include <stdlib.h> int add( int a, int b ) { int result; result = a + b; return result; } int main () { /* char *a = "print \"Hello from C!\\n\";"; */ code(); return 0; } END_C print "Everything went well ;)","\n";
My Example.pm file to load dll / so libraries (works well):
package Example; use 5.006; use strict; use base qw/Exporter DynaLoader/; our $VERSION = '0.00'; our @EXPORT_OK = qw/hello/; bootstrap Example $VERSION; 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Extending perl with C dynamic library.
by syphilis (Archbishop) on Aug 21, 2013 at 22:30 UTC | |
by Martin90 (Sexton) on Aug 24, 2013 at 12:13 UTC |