Builing a library

Tom Browder tom3@fwb.asi.srs.com
Tue Jun 17 13:14:00 GMT 2003


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of sundaresh venugopal

>This is a basic beginners question. How do I build a library from a
>collection of .o files. I thought ar -rcs library.a files.o might work. But
>linking  with this library return's undefined reference errors. If however
>I compile and link directly with the .o files ,the program compiles and
>works >properly.

The problem I believe is you are using the option "r" (replace)with
"c"(create). As I read the man page, if you use "r" and the member doesn't
exists, you will get an error message and the archive will NOT be changed.
(I'll bet the size of your library is nearly zero bytes.) Try executing "ar
-cs library.a [f1.o f2.o ...]" and that should work.

Tom Browder
SRS Technologies, Inc.
838 N. Eglin Parkway, Suite 202
Fort Walton Beach, FL  32547
Tel: 850-862-4188
Fax: 850-862-8055




More information about the Gcc-help mailing list