Mail Archives: djgpp/2004/12/17/12:36:03

X-Authentication-Warning: mail set sender to djgpp-bounces using -f
Date: Fri, 17 Dec 2004 12:35:51 -0500
Message-Id: <>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <>
(fbarbuto2002 DOT no AT w1 DOT ca DOT vip DOT scd DOT yahoo DOT com)
Subject: Re: Linking libraries
References: <32gj6cF3mhujqU1 AT individual DOT net>
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

>     gcc -o test.exe test.c -l apfloat.a
>     gcc -c test.c
>     gcc test.o apfloat.a -o test.exe

What you should have done is kept the file (apfloat.a) in the same
directory as the objects (test.o), and treated it like any other
object (that's all a library is, is a collection of objects).

The moving it to the system library directory thing is for system
libraries.  To use that feature, you must do ALL of the following:

1. Move the file to the djgpp\lib directory.

2. Rename the file to have a "lib" at the beginning and ".a" at the
   end.  For example: libapfloat.a

3. Use the -l option to indicate the MIDDLE part of the name.  For
   example: -lapfloat for the above libapfloat.a

The "-l" option does not specify a file name, it specifies a library
ID.  How gcc uses that to find the library file varies from system to
system (for example, mips platforms often have multiple libapfloat.a
files in multiple directories, which one is chosen depends on other
gcc options like big/little endian or soft/hard float; on linux
systems it looks for /lib/, etc).

- Raw text -

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