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> Date: Mon, 23 Mar 2015 02:23:51 -0500 Message-ID: <85lhiomb20.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt) Cancel-Lock: sha1:2qTyo+YZfDzXfmiaBzdzIVYFdh0= MIME-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 70f14550fbf88e3fb833018778 X-Received-Bytes: 1997 X-Received-Body-CRC: 856035953 Xref: news.eternal-september.org comp.lang.ada:25221 Date: 2015-03-23T02:23:51-05:00 List-Id: 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". 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