--start-group 和 --end-group 命令行选项是什么? [英] What are the --start-group and --end-group command line options?

查看:37
本文介绍了--start-group 和 --end-group 命令行选项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些命令行选项的目的是什么?请帮忙解读以下命令行的含义:

What is the purpose of those command line options? Please help to decipher the meaning of the following command line:

-Wl,--start-group -lmy_lib -lyour_lib -lhis_lib -Wl,--end-group -ltheir_lib

显然它与链接有关,但 GNU 手册没有说明分组的确切含义.

Apparently it has something to do with linking, but the GNU manual is quiet what exactly grouping means.

推荐答案

用于解决几个库之间的循环依赖(列在 -(-) 之间).

It is for resolving circular dependences between several libraries (listed between -( and -)).

引用 为什么库链接的顺序有时会导致 GCC 出错?man ld http://linux.die.net/man/1/ld

-( archives -)--start-group archives--end-group

archives 应该是一个存档文件列表.它们可以是显式文件名,也可以是 -l 选项.

The archives should be a list of archive files. They may be either explicit file names, or -l options.

重复搜索指定的档案,直到没有新的未定义引用被创建.通常,存档仅按照在命令行中指定的顺序搜索一次.如果需要该存档中的符号来解析稍后出现在命令行上的存档中的对象所引用的未定义符号,则链接器将无法解析该引用.通过对档案进行分组,它们都会被重复搜索,直到所有可能的引用都被解析.

The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line. If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference. By grouping the archives, they all be searched repeatedly until all possible references are resolved.

使用此选项会产生显着的性能成本.最好仅在两个或多个存档之间存在不可避免的循环引用时才使用它.

Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives.

因此,组内的库可以多次搜索新符号,并且不需要像 -llib1 -llib2 -llib1

So, libraries inside the group can be searched for new symbols several time, and you need no ugly constructs like -llib1 -llib2 -llib1

PS 归档基本上是一个静态库(*.a 文件)

PS archive means basically a static library (*.a files)

这篇关于--start-group 和 --end-group 命令行选项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆