comp.lang.ada
 help / color / mirror / Atom feed
* Help Linking Shared Objects for Library Use
@ 2018-04-28 19:07 patrick
  2018-04-28 20:32 ` Simon Wright
  0 siblings, 1 reply; 3+ messages in thread
From: patrick @ 2018-04-28 19:07 UTC (permalink / raw)



Hi Everyone

I am trying a new approach(for me) in terms of mixing C and Ada. I want to compile C object code and install system wide in my /usr/local/

I have this program:

with cow ;

procedure barn is
x : integer ;
begin
x := cow.moo ;
end barn ;


It "withs" this program:

package cow is

function  moo  return integer;
pragma import (C, moo, "moo") ;

end cow ;

This Ada library code should call this C code:

#include "sounds.h"
#include <stdio.h>

int moo(){
 printf("cow says moooo\n") ;
return 0;
}


Which also has a header:

int moo(void) ;


I have a little build.sh script which is run to build the shared object from the C code:

gcc -c -Wall -Werror -fpic sounds.c
sudo cp sounds.h /usr/local/include
sudo gcc -shared sounds.o  -o /usr/local/lib/libsounds.so

If I run at the command line, I get this error:

gnatmake barn.adb -lsounds
gcc-4.6 -c -lsounds barn.adb
gcc-4.6 -c -lsounds cow.ads
gnatbind -x barn.ali
gnatlink barn.ali
./barn.o: In function `_ada_barn':
barn.adb:(.text+0x9): undefined reference to `moo'
collect2: ld returned 1 exit status
gnatlink: error when calling /usr/bin/gcc-4.6
gnatmake: *** link failed.
 

When I look at the Ada library code installed from my repo it has .ali files but I don't think I am generating cow.ali

Is there a step I am missing to build cow.ads properly? or am I doing something else wrong?

Thanks for reading-Patrick



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

end of thread, other threads:[~2018-04-28 21:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-28 19:07 Help Linking Shared Objects for Library Use patrick
2018-04-28 20:32 ` Simon Wright
2018-04-28 21:01   ` patrick

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