tags:

views:

125

answers:

1
+2  Q: 

64 Bit Error?

relocation truncated to fit: R_X86_64_PC32 against `.bss'

I'm getting this linker error in g++ when compiling:

The rest of the code isn't material since this definition breaks my compilation. The time function is found in sys/time.h. Compiled on 64-Bit RHEL.

 long ntime() {

     struct timeval tp;

     gettimeofday(&tp, (struct timezone *)0);
     return (tp.tv_sec*1000 + tp.tv_usec / 1000);
 }

Tell me why this is wrong?

Thanks in advance.

+5  A: 

Not sure why the linker error is occuring, but is there any particular reason for making the struct timeval static? Making it local is just as fast and makes your function threadsafe, while conserving heap (well, bss) space.

Edit: Here's the problem. You've exceeded 2GB in static heap space. Make some of that dynamically allocated, or change the memory model. In gcc this can be done by passing -mcmodel=medium and must be used on all object files. This may increase overhead somewhat, however.

bdonlan
That's a good point, probably a bug I would've encountered later. I've since fixed this (though the error persists), and the reason it was static was simply because I'm porting this to a threaded application from an MPI app.
Sam
You, my friend, are a baller.
Sam