www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/08/31/01:18:23

Date: Thu, 31 Aug 1995 06:40:23 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Michael Hagan <hagan AT navresfor DOT navy DOT mil>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Problem with ld.exe

On Wed, 30 Aug 1995, Michael Hagan wrote:

> do the 'gnatbl -o hello.exe hello.ali', it thinks for about 20 seconds,  
> then gives the message 'c:/ada/djgpp/bin/ld.exe: cannot open -lgnat:  
> file not found'.  I ran the gcc and gnatbl commands from the c:\ada\gnat  
> subdirectory.  My path statement and all set statements relfect gnat and  
> djgpp being in the /ada directory.  I am running on a Zenith Z-Station  

Gcc is told to link in a library whose filename libgnat.a, but it cannot 
find it.  The option -l<libname> means ``look for library named 
lib<libname>.a''.  Gcc cannot find it, so (as last resort before giving 
up) it tries to interpret -lgnat as a file with that name, which also 
fails.

To solve this, add -v to your compilation/link command line.  I don't 
work with GNAT, but I'd guess that its compilation driver works like gcc 
(if it ain't gcc itself): when given ``-v'', it should print gobs of 
information about the directories where it looks for various files.  What 
you should look for is the line where it invokes ld.exe.  That line 
should have -L switch with the name of the directory where your Ada 
libraries reside.  (That assumes that your installation indeed has a file 
named libgnat.a somewhere; you should check this up front.)  If that 
directory does NOT appear, then your installation is not correct.  The 
libraries are looked in a directory mentioned in the LIBRARY_PATH 
environment variable.  The DJGPP FAQ list explains this:

8.10  Q: I give all the libraries to gcc, but I still get unresolved
         externals when I link.  What gives?
      A: Ld is a one-pass linker, it only scans each library once looking
         for unresolved externals it saw UNTIL THAT POINT.  This means the
         relative position of object files and library names on the
         command line is significant.  You should put all the libraries
         AFTER all the object files, and in this order:

                      -lgpp -lgpl -lm -lpc

         If you have any libraries of your own, put them BEFORE the above
         system libraries.

         If your installation tree is different from the default, i.e., if
         you keep the libraries NOT in the default lib/ subdirectory, then
         you should add that directory to the line in the [gcc] section of
         your DJGPP.ENV file which starts with LIBRARY_PATH, or put into
         your environment a variable called LIBRARY_PATH and point it to
         the directory where you keep the libraries.

For the DJGPP.ENV solution to work, you should set the DJGPP environment 
variable to point to its pathname:

	set DJGPP=c:/ada/djgpp/djgpp.env

(I've guessed that pathname from your posting, but you should check where 
that file is actually kept.)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019