From: "Pedro Jose Garcia Gil" <pggil@isa.upv.es>
Subject: Interfacing a subprogram from C.
Date: Thu, 28 Feb 2002 16:11:46 +0100
Date: 2002-02-28T15:12:20+00:00 [thread overview]
Message-ID: <a5lhck$6va$1@polaris.cc.upv.es> (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.
next reply other threads:[~2002-02-28 15:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-28 15:11 Pedro Jose Garcia Gil [this message]
2002-02-28 17:50 ` Interfacing a subprogram from C sk
2002-02-28 18:12 ` Pedro Garcia Gil
2002-02-28 18:15 ` Jerry van Dijk
2002-02-28 23:01 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox