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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,889b07ac9e6ac6a3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.204.153.5 with SMTP id i5mr163987bkw.1.1330545639718; Wed, 29 Feb 2012 12:00:39 -0800 (PST) Path: t13ni84561bkb.0!nntp.google.com!news2.google.com!postnews.google.com!c21g2000yqi.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Using dll from a C# code Date: Wed, 29 Feb 2012 12:00:39 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <3622013.252.1330516368698.JavaMail.geo-discussion-forums@ynkz21> NNTP-Posting-Host: 24.230.151.194 Mime-Version: 1.0 X-Trace: posting.google.com 1330545639 16516 127.0.0.1 (29 Feb 2012 20:00:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Feb 2012 20:00:39 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c21g2000yqi.googlegroups.com; posting-host=24.230.151.194; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-02-29T12:00:39-08:00 List-Id: On Feb 29, 5:52=A0am, "Rego, P." wrote: > Hello, > > I have a method in C# which I need to export to Ada using a dll. Maybe > > // simple.cs > // compile with csc /t:library simple.cs > using System; > public class VerifyClass{ > =A0 =A0 =A0 =A0 public bool Verify(){ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return true; > =A0 =A0 =A0 =A0 } > > } > > In order to use the function Verify() in Ada, I need to import this to so= mething like > -- simple.ads > package Simple is > =A0 =A0 =A0 =A0 function Verify return Boolean; > =A0 =A0 =A0 =A0 pragma Import > =A0 =A0 =A0 =A0 (Convention =A0 =A0=3D> dll, > =A0 =A0 =A0 =A0 Entity =A0 =A0 =A0 =A0=3D> Verify, > =A0 =A0 =A0 =A0 External_Name =3D> "Verify"); > end Simple; > > And I could use with > -- main.adb > -- build with gnatmake main -largs -lsimple > with Text_IO; use Text_IO; > with Simple; use Simple; > procedure Main is > begin > =A0 =A0 =A0 =A0 Put_Line (Boolean'Image (Verify)); > end Main; > > When I build the Ada with > gnatmake main -largs -lsimple > > the compiler returns me > ./main.o(.text+0xd6):main.adb: undefined reference to `Verify@0' > > So what have I missed? Maybe the C# code structure should be changed? You have to be sure you are using the compiler for .NET; I think there's something about qualifying names too, but I don't remember what. You may want to check out the import pragma on page 16 in this pdf: http://www.usafa.edu/df/dfe/dfer/centers/accr/docs/carlisle2006b.pdf