sinister
sinister

Reputation: 31

gcc throwing error relocation truncated to fit: R_X86_64_32 against `.bss'

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int dp[100000][100000];
int main()
{
    long int n;
    cin>>n;
    vector <int> a(n);
    for(long int i=0;i<n;i++)
        cin>>a[i];
    memset(dp,0,sizeof(dp));
    long long int maxi=0;
    for(long int i=0;i<n;i++)
    {
        for(long int j=i;j<n;j++)
        {
            dp[i][j]=dp[i][j-1]^a[j];
             dp[i][j]%=mod;
             if(maxi<dp[i][j])
                 maxi=dp[i][j];
        }
    }
    cout<<maxi;
    return 0;
}       

compiler throwing error : In function _GLOBAL__sub_I_dp': (.text.startup+0x185): relocation truncated to fit: R_X86_64_32 against.bss' (.text.startup+0x194): relocation truncated to fit: R_X86_64_32 against `.bss' error: ld returned 1 exit status what is this error ?

Upvotes: 1

Views: 5106

Answers (1)

Baum mit Augen
Baum mit Augen

Reputation: 50043

Your global array takes up 40GB; you can't put that in the program's .data section. It doesn't fit there.

Even if it did, you would end up with a gigantic binary, so it's a bad idea in the first place.

If you have like 45+GB RAM installed, you can use a dynamic allocation (via std::vector) for this, otherwise, rethink your code to need less memory.

Upvotes: 2

Related Questions