使用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.
以后要注意这一点。
《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.
以后要注意这一点。
相关文章推荐
- 使用LD链接时候文件的顺序
- Ubuntu 16.04使用NASM编译时用ld链接程序出现:i386 架构于输入文件 sandbox.o 与 i386:x86-64 输出不兼容(I386 architecture in the input file sandbox.o is not compatible with i386: x86-64 output)
- 使用CMAKE链接外部的动态库时找不到库文件解决办法(/usr/bin/ld: cannot find lxxx)
- Keil5.15使用GCC编译器链接.a库文件
- [Linux文件属性]使用symlink函数建立符号链接文件
- 使用XmlDocument 编辑配置文件修改数据库链接
- 创建Accress 数据库连接文件UDL/如何使用 ADO 的数据链接文件
- 提交含有文件的表单集合的时候使用
- 使用Spring中Src下 -context.xml : 用资源文件夹保存数据库的链接信息 并在配置文件里读取
- 当页面上任意一个链接被点击的时候,alert出这个链接在页面上的顺序号
- Shell脚本中使用for循环和cat命令实现按顺序合并文件
- 运行phpmyadmin的时候下方总是出现“wapm您配置文件中的设置 (空密码的 root) 与 MySQL 默认管理员账户对应。您的 MySQL 服务器使用默认值运行
- 使用cvs的时候,WEB-INF/classes中不能编译生成class文件的原因?
- 使用SSH在做插入和修改的时候即使数据库中给字段设置了默认值还是没有用,在表对应的配置文件中也不知道该如何配置。。请教下。。
- 注意:因博客园服务器搬迁,本BLOG有关图片、下载文件、链接等失效。请不要尝试使用可能弹出的证书。
- 使用GruntJS链接与压缩多个JavaScript文件
- 目标文件和库文件的链接顺序
- 使用GruntJS链接与压缩多个JavaScript文件
- 使用Servlet实现文件下载的时候,避免浏览器自动打开文件
- VC6使用VS2005(VS2008)的lib库文件,去除RTC链接错误