delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/22/00:16:30

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Linking with DJGPP
Date: Thu, 21 May 1998 23:03:46 -0400
Organization: Two pounds of chaos and a pinch of salt.
Lines: 51
Message-ID: <3564EB12.6077@cs.com>
References: <3564D712 DOT 8F5E4C4A AT pathcom DOT com>
NNTP-Posting-Host: ppp116.cs.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Plamen Petkov wrote:
> 
> I am having trouble linking from the command line. For example:
> 
> ld -Ld:/djgpp/allegro/lib/djgpp/ -lliballeg -oex1.exe ex1.o
> 
> generates the following error:
> 
> d:/djgpp/bin/ld.exe: cannot open -lliballeg: No such file or directory
> (ENOENT)
> 
> I have tried giving the full path, with and without the .a extension,
> the DOS and the UNIX slashes, but all combinations fail.

First, you should not be invoking the linker manually unless you exactly
duplicate the command line switches that DJGPP's gcc passes to it. 
You're missing several crucial elements, such as the C library, the
runtime code, and the linker script.  Type "gcc -v ..." to see how the
linker is actually invoked by the compiler.

However, you don't need to invoke the linker manually at all.  If you
tell gcc to take an object file and produce an .exe as output, it will
automatically understand that you want it to invoke the linker.

The error about the library is simple:  when you pass ld the '-l'
parameter, it assumes the 'lib' in front and the '.a' at the end.  So
all you need to pass is '-lalleg'.  The reasons for this are historical.

Additionally, you must add the library parameter to the end of your
command line, not the beginning; otherwise the one-pass linker will see
it before it knows that it needs anything from the library, and you'll
get a whole bunch of undefined references.

Finally, Allegro's makefile should automatically place liballeg.a into
your main DJGPP lib directory, so there shouldn't be any need to specify
the library path manually.  If it didn't, you should copy liballeg.a
into that directory manually.

Here's a command line that should work:

    gcc -o ex1.exe ex1.o -lalleg

hth!

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "History does not record anywhere at |
|       aka Fighteer I       | any time a religion that has any     |
|   mailto:fighteer AT cs DOT com   | rational basis."                     |
| http://www.cs.com/fighteer |                - Lazarus Long        |
---------------------------------------------------------------------

- Raw text -


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