comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: calling Ada dll from C?
Date: Mon, 23 Mar 2015 02:23:51 -0500
Date: 2015-03-23T02:23:51-05:00	[thread overview]
Message-ID: <85lhiomb20.fsf@stephe-leake.org> (raw)
In-Reply-To: lysicyv3f3.fsf@pushface.org

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".

Does anyone know why the loader does not say _which_ file is not found?
It is _extremely_ frustrating to not be able to better diagnose this!

I guess I can use a simple C main (rather than Emacs, to reduce the
number of files accessed), and try strace.

-- 
-- Stephe


  reply	other threads:[~2015-03-23  7:23 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 [this message]
2015-03-23  8:36     ` Dmitry A. Kazakov
2015-03-23 13:42     ` Patrick Noffke
2015-03-25 20:48     ` Stephen Leake
replies disabled

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