From: Rob Solomon on
On Tue, 20 Oct 2009 19:14:46 -0400, Rob Solomon
<usenet(a)drrob1-noreply.com> wrote:

>Finally got it to work. I also found that the order of these options
>in the Linker clause is important. This worked:
>
>package Linker is
> for Default_Switches("Ada") use ("-lm","-lcurses","-lgnarl");
>end linker;
>
>I almost cannot believe it worked.
>
>Now I have to try some of the other examples.

I tried all of the examples using the .gpr file as a template. All
compiled and worked.

Now I need to understand more about how this works.

Thanks for all your help.
From: Ludovic Brenta on
Rob Solomon wrote:
> Now I need to understand more about how this works.

In a nutshell:

- The compiler (gcc-4.3) reads the Ada or C source files and produces
one object file per compilation unit.
- The archiver (ar) takes object files and concatenates them together
into a static library (lib*.a)
- The linker (ld) takes object files and produces a shared library
(lib*.so). The object files for a shared library must have been
compiled with the option -fPIC to produce Position-Independent Code.
- The linker (ld) then takes object files, static libraries and shared
libraries to produce an executable file. It works this way:

1. It copies all the object files into the executable, adjusting
addresses as necessary.
2. If the object files in the executable call subprograms in the
static libraries, it copies the corresponding object files from the
static libraries into the executable, adjusting addresses as
necessary.
3. If the object files in the executable call subprograms in the
shared libraries, it does NOT copy them; instead, it inserts stub
subprograms into the executable.
4. When the program runs, the stubs call into the shared libraries.

gnatmake with a project file automates this. It decides when to call
gcc-4.3 (i.e. which Ada files need recompiling), then it calls
gnatbind and finally gnatlink, passing it all the static and shared
libraries as parameters. gnatlink in turn calls ld.

In your project, you do not produce any library, so you do not call ar
or ld explicitly. This was done on the build machine that produced the
binary packages libtexttools-dev and libtexttools2.0.5. What you do is
link the shared libraries into your executable, i.e. insert the stubs
into your executable. You can try:

ldd basic

to see which shared libraries "basic" will load at run time.

--
Ludovic Brenta.