comp.lang.ada
 help / color / mirror / Atom feed
* Interfacing a subprogram from C.
@ 2002-02-28 15:11 Pedro Jose Garcia Gil
  2002-02-28 17:50 ` sk
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Pedro Jose Garcia Gil @ 2002-02-28 15:11 UTC (permalink / raw)


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");

 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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-02-28 23:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox