nik*_*iko 3 gcc static-libraries
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
Run Code Online (Sandbox Code Playgroud)
实际上我已经搜索了静态库,我发现这 4 个命令可用于在 gcc 中创建静态库。在之前的 stackoverflow 答案中搜索了 2 个命令。我想知道的是,有什么区别在这 4 个命令之间?他们在任何方面创建静态库是否有所不同。因为我们可以按照一个命令来创建一个静态库,但为什么我们有 4 个命令来创建一个静态库。这些让我相信所有 4 个命令之间一定存在差异。我在谷歌上尝试过,但他们给出了命令,但我没有发现它们之间的差异。所以有人知道为什么我们在创建时有 4 个命令要处理静态库?它们之间有什么区别?我的意思是 rs、rcs、rvs,为什么我们有它们?
从 man ar
Run Code Online (Sandbox Code Playgroud)-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.