comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jeffrey.carter@boeing.com>
Subject: Re: Interfacing a subprogram from C.
Date: Thu, 28 Feb 2002 23:01:03 GMT
Date: 2002-02-28T23:01:03+00:00	[thread overview]
Message-ID: <3C7EB6AF.B2738E8@boeing.com> (raw)
In-Reply-To: a5lhck$6va$1@polaris.cc.upv.es

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 <stdio.h>
> 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



      parent reply	other threads:[~2002-02-28 23:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-28 15:11 Interfacing a subprogram from C Pedro Jose Garcia Gil
2002-02-28 17:50 ` sk
2002-02-28 18:12   ` Pedro  Garcia Gil
2002-02-28 18:15 ` Jerry van Dijk
2002-02-28 23:01 ` Jeffrey Carter [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox