Discussion:
Building shared libs with Ada
(too old to reply)
Makhno
2007-07-16 21:36:38 UTC
Permalink
Hello there,
I've been trying all afternoon to build and link to a shared library out
of some ADA code. The ADA builds fine, and I *think* it's building into
a shared library with the following commands:

gnatmake -fPIC myadacode
gcc -shared -o libmyadacode.so *.o -lc

I then take the built binary, libmyadacode.so and try to link it into an
application, like so

gcc -o MyApp -lm -L. -lmyadacode $(FILES)

It looks like it's linking to the exported Ada symbols from
libmycode.so, but I keep getting a load of other linker errors, for example:

./libmyadacode.so: undefined reference to
`system__soft_links__set_jmpbuf_address_soft'

some of these look like Ada library stuff, so it looks like I'm not
linking in some important Ada library.

There seems to be no documentation online about how to build Ada shared
libs, only Win32 DLLs.

Has anyone any suggestions? Thanks
Makhno
2007-07-16 22:59:59 UTC
Permalink
Post by Makhno
Hello there,
I've been trying all afternoon to build and link to a shared library out
of some ADA code. The ADA builds fine, and I *think* it's building into
gnatmake -fPIC myadacode
gcc -shared -o libmyadacode.so *.o -lc
I then take the built binary, libmyadacode.so and try to link it into an
application, like so
gcc -o MyApp -lm -L. -lmyadacode $(FILES)
It looks like it's linking to the exported Ada symbols from
./libmyadacode.so: undefined reference to
`system__soft_links__set_jmpbuf_address_soft'
some of these look like Ada library stuff, so it looks like I'm not
linking in some important Ada library.
There seems to be no documentation online about how to build Ada shared
libs, only Win32 DLLs.
Has anyone any suggestions? Thanks
Some sort of solution;

Apparently I need to link to -lgnat, but in order to do that I need to
tell the linker where it is (ADALIB) using 'gnatls -v' and then use

gcc -shared -o libmyadacode.so *.o -lc -L${ADALIB} -lgnat

However, when I build my main program, I then get linker errors to
__cxa_begin_catch and co, which go away when I link to -lstdc++ (don't
understand why this is needed).

If you have some experience of calling Ada code from C, you'd know that
you have to call the functions adainit and adafinal. Unfortunately,
these do not appear to be to reside in -lgnat, so I get linker errors
for them.

Loading...