Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't help with the Perl side (you require 5.14, Mac OS X has 5.12, Debian 6 has 5.10). That said, I can help with building the library for a C main and direct linking ...</p> <p>The GNAT build process is sufficiently complicated that there are two tools to support it, <code>gnatmake</code> and <code>gprbuild</code>. It’s likely (writing at September 2015) that <code>gnatmake</code> will lose the ability to build libraries, so <code>gprbuild</code> is the better option.</p> <p>I think you need a <i>stand-alone library project</i> (that is, one with the initialization and finalization operations that control Ada elaboration; if you don't initialize the Ada library, you'll get SEGVs or other bad behaviours). You'll find the lowdown on building one <a href="http://docs.adacore.com/live/wave/gprbuild/html/gprbuild_ug/gprbuild_ug/gnat_project_manager.html#stand-alone-library-projects" rel="nofollow noreferrer">here</a>.</p> <p>The <code>greeter.gpr</code> I wrote is</p> <pre><code>project Greeter is for Library_Name use "greeter"; for Library_Kind use "relocatable"; for Library_Dir use "lib"; for Library_Interface use ("greeter"); for Library_Auto_Init use "true"; -- the default, I think for Object_Dir use ".build"; -- to keep temp objects out of the way end Greeter; </code></pre> <p>The <code>Library_Name</code> attribute controls the name of the library; <code>libgreeter.dylib</code> on Mac OS X, <code>libgreeter.so</code> on Linux.</p> <p>The <code>Library_Kind</code> attribute could alternatively be <code>"static"</code>, in which case the name would be <code>libgreeter.a</code>. However, <em>stand-alone libraries must be relocatable</em>.</p> <p>The <code>Library_Dir</code> attribute, which you have to supply (with the two above) to make a library at all, controls where the library is created; in this case, in <code>lib/</code>.</p> <p>You have to supply the <code>Library_Interface</code> attribute to make it a stand-alone library and generate the initialization and finalization operations that control Ada elaboration. They're called <i>library_name</i><code>init</code> and <i>library_name</i><code>final</code> - here, <code>greeterinit</code>, <code>greeterfinal</code>.</p> <p>If <code>Library_Auto_Init</code> is <code>"false"</code> you have to call the initialization and finalization operations yourself, if <code>"true"</code>, they're managed automagically.</p> <p>OK, build the library by</p> <pre><code>gprbuild -p -P greeter </code></pre> <p>(<code>-p</code> says "create any needed output directories", <code>-P</code> specifies the project file).</p> <p>I built <code>greeter.c</code></p> <pre><code>#include &lt;stdio.h&gt; extern void greeter_hello(); int main() { greeter__hello(); return 0; } </code></pre> <p>using</p> <pre><code>$ gcc greeter.c -o greeter -L lib -l greeter </code></pre> <p>and run (on Linux) using</p> <pre><code>$ LD_LIBRARY_PATH=./lib ./greeter </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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