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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bc23fdf9fe2f2080 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-28 15:15:42 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!news-out.visi.com!hermes.visi.com!uunet!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: Interfacing a subprogram from C. X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3C7EB6AF.B2738E8@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: Mime-Version: 1.0 Date: Thu, 28 Feb 2002 23:01:03 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:20613 Date: 2002-02-28T23:01:03+00:00 List-Id: Pedro Jose Garcia Gil wrote: > > Hello. > > I want to use a function in C to program in Ada95. > > For example (I have included all the realized steps.): > > %%%%%%%%%%%% file "pepe.c" %%%%% > #include > void pintar(int a){ > printf("The number is : %d \n",a); > } > %%%%%%%%%%%% > > $gcc -c pepe.c > > %%%%%%%%%%% file prueba.adb %%% > with Ada.Text_IO; use Ada.Text_IO; > > procedure prueba is > pragma linker_options("prueba.o"); I suggest you want "pepe.o" here. > > procedure pintar(dato: integer); > pragma import(C,pintar,"pintar"); > a: integer:=7; > > begin > pintar(a); > end prueba; > > %%%%%%%%%%%%%% > > $gnatmake prueba.adb > >>>>>>>>>>>>>>>>>>>>>>>>> > gnatbind -x prueba.ali > gnatlink prueba.ali > prueba.o: In function `_ada_prueba': > prueba.o(.text+0x0): multiple definition of `_ada_prueba' > ./prueba.o(.text+0x0): first defined here > ./prueba.o: In function `_ada_prueba': > ./prueba.o(.text+0x10): undefined reference to `pintar' > prueba.o: In function `_ada_prueba': > prueba.o(.text+0x10): undefined reference to `pintar' > gnatmake: *** link failed. > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > What am I doing wrong?. > > It's necessary to compile with other options or include some file in > somewhere?. > > Thank you very much. > > Pedro. -- Jeffrey Carter