3
       ar crf library.a file1.o file2.o 
       ar rvs library.a.a file1.o file2.o
       ar rs liblprprint.a lpr_print.o
       ar rcs library.a file1.o file2.o  

Actually I have googled about the static library and I found these 4 commands that can be used to create a static library in gcc.Out of 2 are searched in the previous answers of stackoverflow .The thing I want to know is, Is there any difference between these 4 commands? Do they differ in creating a static library in any aspect. because we can follow one command to create a static library but why do we have 4 commands to create a static library. These made me believe there must be a difference between all the 4 commands.I tried it on google but they gave the command but i did not find the differnces between them.So does anybody know why do we got 4 commands to work on while creating a static library?What would be the difference between them? I mean rs,rcs,rvs, why we have them?

niko
  • 9,285
  • 27
  • 84
  • 131
  • http://stackoverflow.com/questions/5947067/how-to-create-a-static-library-with-g If you check the above answers of that question people used 2 different commands in creatin a static library.why we dont we have a standard command or is there any difference? – niko Jul 13 '11 at 07:19

1 Answers1

6

From man ar

 -c       Suppresses the diagnostic message that  is  written
          to  standard  error  by  default  when  archive  is
          created.

 -r       Replaces or adds files in archive. If archive  does
          not  exist,  a  new  archive  file is created.

 -v       Gives verbose output. When used  with  options  -d,
          -r,  or  -x,  the -v option writes a detailed file-
          by-file description of the archive creation and the
          constituent  files,  and maintenance activity.

 -s       Forces the regeneration of the archive symbol table
          even  if ar is not invoked with an option that will
          modify the archive contents.
spraff
  • 32,570
  • 22
  • 121
  • 229