请解释这个链接错误:参考.rodata [英] Please explain this linking error: referenced in section .rodata

查看:285
本文介绍了请解释这个链接错误:参考.rodata的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个32位SLES10机器。使用GCC 3.4.2



这是一个示例错误

  .L8245在节中引用`.RODATA'的CMakeFiles / myproj.dir / C ++ / UTIL / MyObj.o:被放弃的部分
定义CMakeFiles的`.gnu.linkonce.t._ZN5boost9re_detail9reg_grep2INS0_21grep_search_predicateIPKcSaIcEEES4_cNS_12regex_traitsIcEES5_S5_EEjT_T0_SA_RKNS_14reg_expressionIT1_T2_T3_EEjT4_'/ myproj.dir / C ++ / UTIL / MyObj.o


解决方案

这通常是由于2个不同的.cpp的被编译不同的编译器开关 - 也使用相同的模板。生成的模板实例可能在他们定义/参考不同,如果所选的实例没有定义/指的是完全一样的符号,作为得到丢弃你可能会得到这个错误的人。



验证所有的.cpp的用完全相同的编译器开关和定义编译。如果这是不可能的,重新排序链接器命令行的.obj文件,特别是尝试移动错误消息obj文件列表的末尾或开头提到的.obj文件。



编辑:



另外,如果你链接到的预建的C ++库,看看你是否可以复制用于构建这些库的编译器开关。


I am doing a build on a 32bit SLES10 machine. Using GCC 3.4.2

Here is a sample error

`.L8245' referenced in section `.rodata' of CMakeFiles/myproj.dir/c++/util/MyObj.o: defined in discarded section
 `.gnu.linkonce.t._ZN5boost9re_detail9reg_grep2INS0_21grep_search_predicateIPKcSaIcEEES4_cNS_12regex_traitsIcEES5_S5_EEjT_T0_SA_RKNS_14reg_expressionIT1_T2_T3_EEjT4_' of CMakeFiles/myproj.dir/c++/util/MyObj.o

解决方案

This is typically due to 2 different .cpp's being compiled with different compiler switches - but also using the same templates. The generated template instantiations may differ in what they define/reference, and if the instantiation that is selected doesn't define/refer to the exact same symbols as the ones that got discarded you may get this error.

Validate that all your .cpp's are compiled with the exact same compiler switches and defines. If this isn't possible, reorder the .obj files on the linker commandline, in particular try to move the .obj files mentioned in the error message to the end or beginning of the .obj file list.

EDIT:

Also, if you're linking against prebuilt c++ libraries, see if you can duplicate the compiler switches used for building these libraries.

这篇关于请解释这个链接错误:参考.rodata的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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