comp.lang.ada
 help / color / mirror / Atom feed
From: "Antonio Martínez" <amartinez@atc.ugr.es>
Subject: Interfacing C and Ada95
Date: Tue, 21 Oct 2003 01:13:14 +0200
Date: 2003-10-21T01:13:14+02:00	[thread overview]
Message-ID: <pan.2003.10.20.23.13.08.847161@atc.ugr.es> (raw)

Hello group.

I'm trying to interface C and Ada95 using gcc and gnat. The question is,
Why I cannot use put_line in my function sumtwo ?

I have this 3 sources (these are very small...)

paquete.ads:
package Paquete is
   function sumtwo(X : in Integer) return Integer;
   pragma Export_Function(Internal=>sumtwo, External=>sumtwo);
end Paquete;


paquete.adb:
with Ada.Text_io; use Ada.Text_Io;
package body Paquete is
   function sumtwo(X : in Integer) return Integer is
   begin
      -- put_line("Hello");
      return X + 2;
   end sumtwo;
end Paquete;

progC.c:

#include <stdio.h>
int sumtwo();
int main() {
  int i = 3;
  printf("%i + 2 = %i\n", i, masdos(3));
  return 0;
}

Ok... now I compile like this:

gnatmake paquete.adb           -> generates paquete.ali & paquete.o
gcc progC.v paquete.o -o progC -> generates progC executable

and it works !!!!   Ok. Now, if I add the 5th line in the file
paquete.adb, which contains put_line("Hello"), the gcc says ...
paquete.o(.text+0x10): In function `sumtwo':

: referencia a `ada__text_io__put_line__2' sin definir
collect2: ld devolviᅵ el estado de salida 1

What is the problem? Do I have to export Ada.Text_IO in any matter?

Thank you.

--
Antonio Martï¿œnez




             reply	other threads:[~2003-10-20 23:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-20 23:13 Antonio Martínez [this message]
2003-10-21  2:02 ` Interfacing C and Ada95 David Marceau
2003-10-21  4:57   ` sk
2003-10-21 15:00 ` Stephen Leake
2003-10-21 22:16   ` Simon Wright
2003-10-21 16:04 ` Antonio Martínez
2003-10-21 17:26   ` sk
replies disabled

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