Re: Debian Sarge: problem with libgnat.so



Martin Klaiber <martinkl@xxxxxxxxxxxxxxxxxx> writes:

> Ludovic Brenta <ludovic@xxxxxxxxxxxxxxxxxx> wrote:
>
>> Your Makefile is correct, except that it calls the C compiler to link
>> your program. If you call gnatgcc instead, you should be fine. By
>> default, gnatgcc looks in /usr/lib/gcc-lib/i486-linux/2.8.1/adalib,
>> but gcc (the C compiler) only looks in /usr/lib.
>
> Hm, gnatgcc gives the same error:

Oops, sorry. I think I meant gnatmake, but even that wouldn't solve
your problem.

> I want to keep it portable with other Linux-distros (if possible) as
> the code is public. Would it be better to use gnatgcc oder gcc then?

I suggest that you hide libgnat from C programmers. To do this, you
link your shared library with libgnat; unfortunately, as things stand
now, you must use the full path for that, like so:

# -*- Makefile -*- snippet
adalib:=/usr/lib/gcc-lib/`gnatgcc -dumpmachine`/`gnatgcc -dumpversion`/adalib

libopensteuer.so.$(major).$(minor): $(OBJECT_FILES)
gnatgcc -shared -o $@ $(OBJECT_FILES) \
-L$(adalib) -lgnat -Wl,--soname,libopensteuer.so.$(major)

install:
cp -p libopensteuer.so.$(major).$(minor) /usr/local/lib
cd /usr/local/lib; \
ln -s libopensteuer.so.$(major).$(minor) libopensteuer.so; \
ln -s libopensteuer.so.$(major).$(minor) libopensteuer.so.$(major)

CFLAGS := -Wall

test_c.o: test_c.c:
gcc -c $< -o $@ $CFLAGS

test_c: test_c.o install
gcc -o $@ $< -lopensteuer
# End of Makefile snippet

If libopensteuer is properly linked with libgnat, then it doesn't
matter what you use to do the final linking: gcc, gnatcc, gnatlink, or
even plain ld.

As to portability, the only standard layout for Ada files is the GNU
Ada Environment Specification[1]. It might be worthwhile to see if we
can improve this standard. Also, the only GNU/Linux distribution I
know of that conforms to this standard is Debian.

[1] http://cert.uni-stuttgart.de/projects/ada/gnae.php

HTH

--
Ludovic Brenta.
.



Relevant Pages

  • Re: Debian Sarge: problem with libgnat.so
    ... why gnatgcc doesn't find ... > If you hide libgnat from C programmers, you can use gnatgcc, adagcc ... They'll use just "gcc" and get libgnat pulled in by your ... > purpose of making it easier to link shared libraries with libgnat. ...
    (comp.lang.ada)
  • Re: Debian Sarge: problem with libgnat.so
    ... > Your Makefile is correct, except that it calls the C compiler to link ... If you call gnatgcc instead, ... > but gcc (the C compiler) only looks in /usr/lib. ... Would it be better to use gnatgcc oder gcc then? ...
    (comp.lang.ada)
  • Re: Debian Sarge: problem with libgnat.so
    ... >>> Your Makefile is correct, except that it calls the C compiler to link ... If you call gnatgcc instead, ... I notice that Ubuntu doesn't have the linker problem shown, ...
    (comp.lang.ada)