comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: calling Ada dll from C?
Date: Wed, 25 Mar 2015 15:48:42 -0500
Date: 2015-03-25T15:48:42-05:00	[thread overview]
Message-ID: <85vbhols5x.fsf@stephe-leake.org> (raw)
In-Reply-To: 85lhiomb20.fsf@stephe-leake.org

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Simon Wright <simon@pushface.org> writes:
>
>> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>>
>>> A related issue is 'adainit'. According to "(gnat_ugn) Binding with
>>> Non-Ada Main Programs", since the main program is not in Ada, I'm
>>> supposed to run gnatbind with -n, and then call 'adainit' from the C
>>> main program.
>>>
>>> However, since I'm only building a dll, not a main program, it appears
>>> gnatbind is not run, so no 'adainit' is generated.
>>
>> You need to build a 'stand-alone library'[1]. If the library is dynamic,
>> the default is to do automatic initialization (i.e. elaboration) on load
>> (and finalization on unload?).
>
> Thanks for the pointer, but that did not help.
>
> I made it work by building a static Ada library, running gnatbind -n on
> that directly to generate adainit, writing a C wrapper to call adainit,
> and building the dll by linking together the C wrapper, the Ada static
> library and the GNAT runtime using 'gcc -shared'.
>
> However, that only works on Windows; Debian still gives "file not
> found".

This was because I'm using the libre GNAT distribution, rather than the
Debian gnat distribution. So I had to set LD_LIBRARY_PATH. I used strace
to find this, but ldd also reported it (not sure why I missed that the
first time I tried ldd).

So now I have an Ada dynamic library that works with Emacs on either
Windows or Debian.

-- 
-- Stephe

      parent reply	other threads:[~2015-03-25 20:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-21  9:43 calling Ada dll from C? Stephen Leake
2015-03-21 14:19 ` Simon Wright
2015-03-23  7:23   ` Stephen Leake
2015-03-23  8:36     ` Dmitry A. Kazakov
2015-03-23 13:42     ` Patrick Noffke
2015-03-25 20:48     ` Stephen Leake [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox