From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,57d6726df7b9ad13 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!postnews.google.com!e34g2000vbm.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: text tools Date: Wed, 21 Oct 2009 01:06:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: <29df0927-1d3d-409e-8ee4-b25730e6238c@e34g2000vbm.googlegroups.com> References: <918b3ebe-ec1b-4334-ac6c-8a1fb5b9f2ee@k4g2000yqb.googlegroups.com> <44acf5f8-f3b3-49b8-bfac-3e35fad8f2b1@q14g2000vbi.googlegroups.com> <6cfcc5de-34bc-4fdb-96ad-5e68eb2d69d9@p23g2000vbl.googlegroups.com> <7ugsd511f0fpp8q22i7rupa6htoooccfu3@4ax.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1256112374 10128 127.0.0.1 (21 Oct 2009 08:06:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 21 Oct 2009 08:06:14 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e34g2000vbm.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8765 Date: 2009-10-21T01:06:14-07:00 List-Id: 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.