delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/13/01:56:53

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199607130546.AA031266811@relay1.geis.com>
Date: Sat, 13 Jul 96 05:30:00 UTC 0000
To: mmhamze AT mail DOT utexas DOT edu
Cc: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Linking into a library usi

Reply to message 5898125    from MMHAMZE AT MAIL. on 07/12/96 12:02PM


>I looked into the docs that come with DJGPP ver2, and I can not seem
>to find the command line switches that I should use to link objects
>(or assemble and compile and link) into a libray (not an exe).  Can
>someone give an example of the command line switches needed to do
>that.

To create a library under DJGPP, you use the 'ar' function.  This is
part of the standard distribution and there's quite comprehensive
online documentation (info Binutils ar).  Simply, to create a library,
do the following:

Compile your code into object files (.o) by giving the -c switch to gcc.
Archive the files into a library with the following command:

ar rvs <mylib.a> <object file> <object file> ...

Thereafter, as long as that library is in the current LIBRARY_PATH as
defined in DJGPP.ENV, you can simply link it with -l when you compile
like any other library.  You could also specify the directory it's in with
the -L switch.

John

- Raw text -


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