From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: calling Ada dll from C? References: <85d2428z3e.fsf@stephe-leake.org> <85lhiomb20.fsf@stephe-leake.org> Date: Wed, 25 Mar 2015 15:48:42 -0500 Message-ID: <85vbhols5x.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt) Cancel-Lock: sha1:+K7Wj9fPs9LlH2cCBiKdlsojMSU= MIME-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 4bd2b55131f2be3fb833016641 X-Received-Bytes: 2203 X-Received-Body-CRC: 3634802583 Xref: news.eternal-september.org comp.lang.ada:25256 Date: 2015-03-25T15:48:42-05:00 List-Id: Stephen Leake writes: > Simon Wright writes: > >> Stephen Leake 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