Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading Ada shared objects in Perl with DynaLoader.pm
    primarykey
    data
    text
    <p>Long time listener, first time caller. I'm aware this is a somewhat obscure question, and don't expect too much. :-)</p> <p>I have the following Ada files:</p> <p><strong>greeter.ads</strong></p> <pre><code>package Greeter is procedure Hello; end Greeter; </code></pre> <p><strong>greeter.adb</strong></p> <pre><code>with Ada.Text_IO; use Ada.Text_IO; package body Greeter is procedure Hello is begin Put_Line ("Hello, world!"); end Hello; end Greeter; </code></pre> <p>And compile them into a shared object like this:</p> <pre><code>gnatmake -z -fPIC greeter.adb gcc -shared -o libgreeter.so greeter.o </code></pre> <p>This compiles fine. <code>nm</code> shows the following symbols:</p> <pre><code>$ nm -D libgreeter.so w _Jv_RegisterClasses 0000000000201028 A __bss_start w __cxa_finalize w __gmon_start__ U __gnat_eh_personality 0000000000201028 A _edata 0000000000201038 A _end 00000000000006a8 T _fini 0000000000000520 T _init U ada__text_io__put_line__2 0000000000201018 D greeter_E 000000000000063c T greeter__hello </code></pre> <p>Now I try to load that shared object in Perl:</p> <pre><code>#!/usr/bin/env perl use 5.014; use strict; use warnings; #BEGIN { $ENV{PERL_DL_DEBUG} = 1 }; package Greeter { use constant ADADIR =&gt; '/usr/lib/gcc/x86_64-linux-gnu/4.4/rts-native/adalib/'; use constant OURDIR =&gt; do { (my $f = __FILE__) =~ s{[^/]+$}//; $f || "." }; require DynaLoader; our @ISA = 'DynaLoader'; my $runtime = DynaLoader::dl_load_file( ADADIR.'/libgnat.so', ) or die DynaLoader::dl_error(); my $gep = DynaLoader::dl_find_symbol( $runtime, '__gnat_eh_personality', ) or die DynaLoader::dl_error(); my $libref = DynaLoader::dl_load_file( OURDIR.'/libgreeter.so', 0x01, ) or die DynaLoader::dl_error(); my $func = DynaLoader::dl_find_symbol( $libref, 'greeter__hello', ) or die DynaLoader::dl_error(); print $func, $/; } </code></pre> <p>But this bombs out with the following message:</p> <p><strong>./libgreeter.so: undefined symbol: __gnat_eh_personality at ./greeter.pl line 26.</strong></p> <p>Does anybody have any hints? Is there something better/easier than DynaLoader that I should be using??</p> <p>I have a repository with all the relevant files here:</p> <ul> <li><a href="https://bitbucket.org/tobyink/ada-perl-mashup">https://bitbucket.org/tobyink/ada-perl-mashup</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    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.
    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