comp.lang.ada
 help / color / mirror / Atom feed
From: patrick@spellingbeewinnars.org
Subject: Help Linking Shared Objects for Library Use
Date: Sat, 28 Apr 2018 12:07:05 -0700 (PDT)
Date: 2018-04-28T12:07:05-07:00	[thread overview]
Message-ID: <a30c613f-e25a-43e1-9ee2-315baade3bbb@googlegroups.com> (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



             reply	other threads:[~2018-04-28 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-28 19:07 patrick [this message]
2018-04-28 20:32 ` Help Linking Shared Objects for Library Use Simon Wright
2018-04-28 21:01   ` patrick
replies disabled

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