comp.lang.ada
 help / color / mirror / Atom feed
* Interfacing C and Ada95
@ 2003-10-20 23:13 Antonio Martínez
  2003-10-21  2:02 ` David Marceau
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Antonio Martínez @ 2003-10-20 23:13 UTC (permalink / 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




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

end of thread, other threads:[~2003-10-21 22:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-20 23:13 Interfacing C and Ada95 Antonio Martínez
2003-10-21  2:02 ` 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

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