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

查看:451
本文介绍了--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

-( 归档文件 -)--start-group 归档文件 --end-group

归档文件应该是归档文件的列表.它们可以是显式文件名,也可以是-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天全站免登陆