Declare a global array of size 10^9

When i am declaring a global array with size 10^9, i am getting this compilation error message.

/home/BGDaEJ/cc92lZ2a.o: In function `_GLOBAL__sub_I_b':
prog.cpp:(.text.startup+0x1b3): relocation truncated to fit: R_X86_64_PC32 against `.bss'
prog.cpp:(.text.startup+0x1d1): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: error: ld returned 1 exit status

Can someone help me resolve this?

have you calculated the needed memory? You should figure out other algo, one that doesn’t need that huge array

4 Likes

refer to this blog