以下命令在makefile中做什么?

问题描述 投票:0回答:1
$(TARGET): build $(OBJECTS)
        ar rcs $@ $(OBJECTS)
        ranlib $@

什么是“ ar rcs”和“ ranlib”?

c makefile
1个回答
0
投票

ar用于创建库(包含编译代码的档案)

man ar:
ar -- create and maintain library archives
...
-r      Replace or add the specified files to the archive
-c      Whenever an archive is created, an informational message to that effect is written to standard error.  If the -c option is speci-
             fied, ar creates the archive silently.
-s      Write an object-file index into the archive, or update an existing one, even if no other change is made to the archive.  You may
             use this modifier flag either with any operation, or alone.  Running `ar s' on an archive is equivalent to running `ranlib' on
             it.

第一个参数是结果库的名称,其他是要在其中插入的目标文件。

[ranlib生成对档案内容的索引,并将其存储在档案中。

© www.soinside.com 2019 - 2024. All rights reserved.