This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Builing a library


-----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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]