简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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