简体   繁体   English

使用 g++ 编译时重定位被截断以适应错误

[英]Relocation truncated to fit error when compiling using g++

I am trying to compile a piece of cpp code under linux, and got the following error:我在linux下尝试编译一段cpp代码,出现如下错误:

/tmp/ccIeh7Ta.o: In function `model::MulPLSA::EStep()':
mul_plsa.cpp:(.text+0xb12): relocation truncated to fit: R_X86_64_32S against symbol `model::MulPLSA::mItemLatRatDeno' defined in .bss section in /tmp/ccIeh7Ta.o
mul_plsa.cpp:(.text+0xb42): relocation truncated to fit: R_X86_64_32S against symbol `model::MulPLSA::mItemLatRatDeno' defined in .bss section in /tmp/ccIeh7Ta.o
/tmp/ccIeh7Ta.o: In function `model::MulPLSA::MStep()':
mul_plsa.cpp:(.text+0xcec): relocation truncated to fit: R_X86_64_32S against symbol `model::MulPLSA::mItemLatRatDeno' defined in .bss section in /tmp/ccIeh7Ta.o
collect2: ld returned 1 exit status

My OS: Ubuntu 10.10我的操作系统:Ubuntu 10.10
g++: gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) g++: gcc 版本 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
Anyone has came across this error before?以前有人遇到过这个错误吗? Thanks.谢谢。

cheng

By default the program is generated in a small code model , which basically means that its symbols must be linked in the lower 2 GB of the address space.默认情况下,程序以小代码模型生成,这基本上意味着它的符号必须链接在地址空间的低 2 GB 中。

If they don't fit, the solution can be to use a medium code model which means that program and small symbols are linked in the lower 2GB of the address space and large symbols are put into large data or bss sections located above 2BG (abstract from man gcc ).如果不合适,解决方案可以使用中码模型,即程序和小符号链接在地址空间的较低 2GB 中,大符号放入位于 2BG 上方的大数据或 bss 部分(抽象来自man gcc )。 Large symbols are defined using -mlarge-data-threshold so some optimizaiton can be done, but note that this value should be same accross all objects.大符号是使用-mlarge-data-threshold定义的,因此可以进行一些优化,但请注意,该值在所有对象中都应相同。

g++ -mcmodel=medium ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM