comp.lang.ada
 help / color / mirror / Atom feed
* Calling Ada (GNAT) from C programs...
@ 1996-03-27  0:00 David Weller
  1996-03-30  0:00 ` Gerd Moellmann
  1996-04-01  0:00 ` michael
  0 siblings, 2 replies; 5+ messages in thread
From: David Weller @ 1996-03-27  0:00 UTC (permalink / raw)


(Posted on c.l.a instead of to report@gnat.com because I think this
issue is of general interest to those that, well, are interested :-)
(But I cc'ed them anyway :-)

I'm trying to get the special GNAT binding feature to work with some C
code and getting unresolved symbols.  I can't seem to find
documentation on it...I have a feeling it's simething simple.

Here's the source:

package Greetings is
        procedure Hello;
        procedure Goodbye;
end Greetings;

with Text_IO;
package body Greetings is

procedure Hello is
begin
        Text_Io.Put_Line("Hello there from Ada-land!");
end Hello;

procedure Goodbye is
begin
        Text_Io.Put_Line("Goodbye, going back to C-land :-( ");
end Goodbye;

end Greetings;

/* main.c */
main (){
        /* Initialize Ada runtime */
        adainit();

        /* Call the routines */
        greetings__hello();
        greetings__goodbye();

        /* Wrap things up */
        adafinal();
}

gnatbind -n greetings.ali is called, then the linkage command is
ld main.o b_greetings.o greetings.o

Which gives...
/usr/lib/ld:
Warning: Unresolved :
system___elabs
interfaces__c_streams___elabs
ada__exceptions___elabs
ada__tags___elabb
ada__streams___elabs
system__tasking_soft_links___elabb
system__secondary_stack___elabb
system__finalization_root___elabs
system__finalization_implementation___elabs
ada__finalization___elabs
ada__finalization__list_controller___elabs
system__file_control_block___elabs
ada__text_io___elabs
system__file_io___elabb
ada__text_io___elabb
system__finalization_implementation__finalize_global_list
ada__text_io__put_line$2

Perhaps an incorrect environment variable?
-- 
		    GNAT = GNAT is Not an Ada Translator
==Ada 95 Booch Components: www.ocsystems.com/booch or www.dfw.net/~dweller==
Reality: Work, Work, Work, Guitar.         | Plugged: Fender Telecaster Deluxe
Fantasy: Guitar, Guitar, Guitar, Work(ha!) | Unplugged: Yamaha CG-150SA




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

* Re: Calling Ada (GNAT) from C programs...
  1996-03-27  0:00 Calling Ada (GNAT) from C programs David Weller
@ 1996-03-30  0:00 ` Gerd Moellmann
  1996-03-30  0:00   ` David Weller
  1996-04-01  0:00 ` michael
  1 sibling, 1 reply; 5+ messages in thread
From: Gerd Moellmann @ 1996-03-30  0:00 UTC (permalink / raw)


dweller@dfw.net (David Weller) writes:

[snip]

> gnatbind -n greetings.ali is called, then the linkage command is
> ld main.o b_greetings.o greetings.o
> 
> Which gives...
> /usr/lib/ld:
> Warning: Unresolved :
> system___elabs
> interfaces__c_streams___elabs

[snip}

> Perhaps an incorrect environment variable?

You must link with the object files (*.o) for the library units that
are named in greetings.ali (system.o etc.).
-- 
Gerd Moellmann, Altenbergstr. 6, D-40235 Duesseldorf, Germany
Software Development & Consulting
Internet: mmann@ibm.net / CIS: 100025,3303 / Phone: +49 211 666 881




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

* Re: Calling Ada (GNAT) from C programs...
  1996-03-30  0:00 ` Gerd Moellmann
@ 1996-03-30  0:00   ` David Weller
  0 siblings, 0 replies; 5+ messages in thread
From: David Weller @ 1996-03-30  0:00 UTC (permalink / raw)


In article <mmanng2aq2y1w.fsf@ibm.net>, Gerd Moellmann <mmann@ibm.net> wrote:
>
>> gnatbind -n greetings.ali is called, then the linkage command is
>> ld main.o b_greetings.o greetings.o
>> 
>> Which gives...[unresolved symbols]
>You must link with the object files (*.o) for the library units that
>are named in greetings.ali (system.o etc.).

Actually, I originally tried that, but it generates a "ripple effect".
The correct command, as Robert Dewar has pointed out, is to follow
that gnatbind command above with
	gnatbl -linkonly greetings.ali main.o

I've also been told this will change to
	gnatlink greetings.ali main.o
with GNAT v3.04

-- 
Ancient man: Web apps? Java!  OO stuff? Eiffel!  "Real-time" stuff? C/C++! 
Modern man: Web apps? Ada 95!  OO stuff? Ada 95!  "Real-time" stuff? Ada 95!
	Not a revolution...but evolution.  http://lglwww.epfl.ch/Ada




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

* Re: Calling Ada (GNAT) from C programs...
  1996-04-01  0:00 ` michael
@ 1996-04-01  0:00   ` Robert Dewar
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1996-04-01  0:00 UTC (permalink / raw)


Michael says

"The easiest way to deal with that problem is to put all .o files from
adalib into an archive, e.g. libgnat-rtl.a and then link your programs
with -lgnat-rtl -lgnat in addition to your own object code (assuming
that these libs are in your library search path). I always wonder why
this is not the normal procedure of gnat anyway."

That is indeed a good idea, but not quite trivial. For example, if
you do this, you will find that pragma Queuing_Policy is a problem.
On SGI and Linux, we do use shared librarie for the runtime, and we
expect to do this on other targets later on.





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

* Re: Calling Ada (GNAT) from C programs...
  1996-03-27  0:00 Calling Ada (GNAT) from C programs David Weller
  1996-03-30  0:00 ` Gerd Moellmann
@ 1996-04-01  0:00 ` michael
  1996-04-01  0:00   ` Robert Dewar
  1 sibling, 1 reply; 5+ messages in thread
From: michael @ 1996-04-01  0:00 UTC (permalink / raw)


dweller@dfw.net (David Weller) wrote:
[...]
> 
> I'm trying to get the special GNAT binding feature to work with some C
> code and getting unresolved symbols.  I can't seem to find
> documentation on it...I have a feeling it's simething simple.
> 
[...]

The easiest way to deal with that problem is to put all .o files from
adalib into an archive, e.g. libgnat-rtl.a and then link your programs
with -lgnat-rtl -lgnat in addition to your own object code (assuming
that these libs are in your library search path). I always wonder why
this is not the normal procedure of gnat anyway.

Michael

-- 
------------------------------------------------------------------------
--Dipl.-Ing. Michael Paus   (Member: Team Ada)
--University of Stuttgart, Inst. of Flight Mechanics and Flight Control
--Forststrasse 86, 70176 Stuttgart, Germany
--Phone: (+49) 711-121-1434  FAX: (+49) 711-634856
--Email: Michael.Paus@ifr.luftfahrt.uni-stuttgart.de (NeXT-Mail welcome)





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

end of thread, other threads:[~1996-04-01  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-27  0:00 Calling Ada (GNAT) from C programs David Weller
1996-03-30  0:00 ` Gerd Moellmann
1996-03-30  0:00   ` David Weller
1996-04-01  0:00 ` michael
1996-04-01  0:00   ` Robert Dewar

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