3

我试图在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

我的操作系统:Ubuntu 10.10
g++:gcc 版本 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
以前有人遇到过这个错误吗?谢谢。

4

1 回答 1

1

默认情况下,程序是在小代码模型中生成的,这基本上意味着它的符号必须链接在地址空间的低 2 GB 中。

如果它们不适合,解决方案可以是使用中等代码模型,这意味着程序和小符号链接在地址空间的较低 2GB 中,而大符号则放入位于 2BG 之上的大数据或 bss 部分(摘要来自man gcc)。大符号是使用-mlarge-data-threshold定义的,因此可以进行一些优化,但请注意,该值在所有对象中应该相同。

g++ -mcmodel=medium ....
于 2012-11-12T15:42:45.197 回答