Note that there are some explanatory texts on larger screens.

plurals
  1. POPerlEmbed - C# - Mono - Linux
    primarykey
    data
    text
    <p>Has anyone attempted using perlembed in Mono on Linux?</p> <p>Here is the link: <a href="http://perldoc.perl.org/perlembed.html" rel="noreferrer">perlembed</a></p> <p>Here is my first attempt at the DllImport signatures:</p> <pre><code>private const string PERL_LIB = "/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so"; [DllImport(PERL_LIB, EntryPoint = "perl_alloc", SetLastError = true)] public static extern IntPtr Alloc(); [DllImport(PERL_LIB, EntryPoint = "perl_construct", SetLastError = true)] public static extern void Construct(IntPtr hPerl); [DllImport(PERL_LIB, EntryPoint = "perl_destruct", SetLastError = true)] public static extern void Destruct(IntPtr hPerl); [DllImport(PERL_LIB, EntryPoint = "perl_free", SetLastError = true)] public static extern void Free(IntPtr hPerl); [DllImport(PERL_LIB, EntryPoint = "perl_parse", SetLastError = true)] public static extern void Parse(IntPtr hPerl, IntPtr @null, int argc, StringBuilder argv, StringBuilder env); [DllImport(PERL_LIB, EntryPoint = "perl_run", SetLastError = true)] public static extern void Run(IntPtr hPerl); [DllImport(PERL_LIB, EntryPoint = "eval_pv", SetLastError = true)] public static extern void Eval(string expr, bool flag); </code></pre> <p>The CORE directory can change per Linux distro. </p> <p>The following code runs, but crashes on the <code>Parse()</code> method:</p> <pre><code>try { Console.WriteLine("Alloc"); IntPtr perl = Alloc(); Console.WriteLine("Construct"); Construct(perl); Console.WriteLine("Parse"); Parse(perl, IntPtr.Zero, 3, new StringBuilder("-e 0"), new StringBuilder()); Console.WriteLine("Run"); Run(perl); Console.WriteLine("Eval"); Eval("$a = 3.14; $a **= 2", true); Console.WriteLine("Destruct"); Destruct(perl); Console.WriteLine("Free"); Free(perl); } catch (Exception exc) { Console.WriteLine(exc.ToString()); } </code></pre> <p>My crash reads:</p> <pre><code>================================================================= Got a SIGSEGV while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application. ================================================================= Stacktrace: in (wrapper managed-to-native) Woot:Parse (intptr,intptr,int,System.Text.StringBuilder,System.Text.StringBuilder) &lt;0x4&gt; in (wrapper managed-to-native) Woot:Parse (intptr,intptr,int,System.Text.StringBuilder,System.Text.StringBuilder) &lt;0xffff9f85&gt; in Woot:Main () &lt;0x8d&gt; in (wrapper runtime-invoke) System.Object:runtime_invoke_void (object,intptr,intptr,intptr) &lt;0x7c79b09&gt; </code></pre> <p>Native stacktrace:</p> <pre><code> mono(mono_handle_native_sigsegv+0xbb) [0x81368fb] mono [0x8105670] [0x4c45a440] /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so(perl_parse+0xa3) [0x4c6e6e93] [0x43ad78] [0x434cae] [0x434abe] mono(mono_runtime_exec_main+0x62) [0x80ae5a2] mono(mono_runtime_run_main+0x152) [0x80af6e2] mono(mono_main+0xef9) [0x805dae9] mono [0x805c702] /lib/libc.so.6(__libc_start_main+0xdc) [0x4c48d724] mono [0x805c651] </code></pre> <p>There are some <code>PERL_SYS_INIT3</code>, and <code>PERL_SYS_TERM</code> calls that <a href="http://perldoc.perl.org/perlembed.html" rel="noreferrer">perlembed</a> mentions, but I have not been able to call those methods through <code>DllImport</code>. I always get <code>EntryPointNotFoundException</code> in those cases. I'm sure they are in a different file I need to import.</p> <p>Can someone direct me in the correct way to call <code>DllImports</code> to perlembed?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload