开发者

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:

/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)开发者_如何学Python: 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

g++: gcc version 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.

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

g++ -mcmodel=medium ....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜