您的位置:首页 > 其它

使用LD链接时候文件的顺序

2011-09-03 14:44 309 查看
将多个.o文件链接成可执行文件的时候。如果链接的顺序不对,会产生错误。

《An introduction of gcc》里面有下面一段话:

On Unix-like systems, the traditional behavior of compilers and linkers

is to search for external functions from left to right in the object files

specified on the command line. This means that the object file which

contains the definition of a function should appear after any files which

call that function.

但是也说了:

Most current compilers and linkers will search all object files, regardless

of order, but since not all compilers do this it is best to follow the

convention of ordering object files from left to right.

所以我遇到的问题很有可能就是gcc不支持search all object files.而是从left to right.
以后要注意这一点。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐