请解释此链接错误:在 .rodata 部分中引用 [英] Please explain this linking error: referenced in section .rodata

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

问题描述

我正在 32 位 SLES10 机器上进行构建.使用 GCC 3.4.2

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

这是一个错误示例

`.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

推荐答案

这通常是由于使用不同的编译器开关编译 2 个不同的 .cpp - 但也使用相同的模板.生成的模板实例可能在定义/引用的内容上有所不同,如果所选实例未定义/引用与被丢弃的符号完全相同的符号,您可能会收到此错误.

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.

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

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.

此外,如果您要链接到预构建的 c++ 库,请查看是否可以复制用于构建这些库的编译器开关.

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天全站免登陆