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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.8.69 with SMTP id 45mr86145647yhq.39.1427118123914; Mon, 23 Mar 2015 06:42:03 -0700 (PDT) X-Received: by 10.182.16.163 with SMTP id h3mr785028obd.26.1427118123857; Mon, 23 Mar 2015 06:42:03 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!h3no4285711qgf.1!news-out.google.com!qk8ni62932igc.0!nntp.google.com!z20no2423418igj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 23 Mar 2015 06:42:03 -0700 (PDT) In-Reply-To: <85lhiomb20.fsf@stephe-leake.org> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=74.203.194.21; posting-account=bXcJoAoAAAAWI5APBG37o4XwnD4kTuQQ NNTP-Posting-Host: 74.203.194.21 References: <85d2428z3e.fsf@stephe-leake.org> <85lhiomb20.fsf@stephe-leake.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: calling Ada dll from C? From: Patrick Noffke Injection-Date: Mon, 23 Mar 2015 13:42:03 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:25225 Date: 2015-03-23T06:42:03-07:00 List-Id: On Monday, March 23, 2015 at 2:23:54 AM UTC-5, Stephen Leake wrote: > 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! > Did you try using strace? Is it as simple as setting your LD_LIBRARY_PATH environment variable? Pat