Sorry for the Ada content herein but I have to cross-bother *someone*. 8^)
I'm trying to get a simple Ada program to access simple Pascal code-- see bottom of this post. (I also want to call Ada code from Pascal, but I haven't tried that yet.)
I've read "6.11.2 Exporting GPC Libraries to Other Languages" from the GPC docs and "2.10.1 Interfacing to C" in the GNAT docs.
I _think_ that I can prepare the Pascal code and call it from Ada assuming C calling conventions; at least, that's what I'm trying.
The command lines that I am using, with the working directory the one containing all the source files, are:
gpc -c mypascalunit.pas -o mypascalunit.o gnatmake adacallspascal.adb -largs mypascalunit.o /Developer/Pascal/ gpc344d2/lib/gcc/powerpc-apple-darwin8/3.4.4/libgpc.a
(the gnatmake command is all one line)
This causes the following output (sorry if there are any impolite line breaks):
gcc -c adacallspascal.adb gnatbind -x adacallspascal.ali gnatlink mypascalunit.o /Developer/Pascal/gpc344d2/lib/gcc/powerpc- apple-darwin8/3.4.4/libgpc.a adacallspascal.ali ld: Undefined symbols: _frommypascalunit gnatlink: cannot call /usr/bin/gcc gnatmake: *** link failed.
I'm linking libgpc.a because I think that is the GPC runtime library and prevents complaints about undefined symbols such as __p_Write_String.
Question: Why doesn't the linker see _frommypascalunit???
Here are the two programs, Ada main and Pascal unit.
with Ada.Text_IO; use Ada.Text_IO; procedure adacallspascal is
procedure frommypascalunit; pragma Import(C, Frommypascalunit);
begin Put_Line("Hello from adacallspascal."); frommypascalunit; end adacallspascal;
unit mypascalunit; interface procedure frommypascalunit; implementation procedure frommypascalunit; begin writeln('Hello from frommypascalunit.'); end; end.
Thanks for any comments at all. I've never tried anything like this.
Jerry