简体   繁体   English

以下命令在 makefile 中有什么作用?

[英]What do the following commands do in makefile?

$(TARGET): build $(OBJECTS)
        ar rcs $@ $(OBJECTS)
        ranlib $@

What are "ar rcs" and "ranlib"?什么是“ar rcs”和“ranlib”?

ar is used to create libraries (that are archives containing compiled code) 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.

The first argument is the name of the resulting libraries, the others are the object files to insert in it.第一个参数是生成的库的名称,其他参数是要插入其中的 object 文件。

ranlib generates an index to the contents of an archive and stores it in the archive. ranlib生成档案内容的索引并将其存储在档案中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM