View Full Version : linking error
I got a "linking error" when I compiled my code:
".code_sqrt.o' can not fit in the section. Section ' code_sqrt.o' length=0x00000442"
what does this mean?
Mark McLeod
19-01-2007, 22:17
It looks like your floating point calculations have completely filled your processors memory.
If you are only using the sqrt function, you might like to see the implementation of InvSqrt():
http://www.beyond3d.com/articles/fastinvsqrt/
here is an implementation that I compiled on my first controller (the scary constant is a standard IEEE754 floating point number, so it will work on every microprocessor the same way).
I would definitely extensively test this method before putting it to use (i.e. don't hook up motors until you are sure it gives the expected answers), but I believe that it is just a first-order Newton's method approximation, with the constant being a first guess I believe.
I'm pretty sure it will take up less space than the included math library.
float invSqrt(float magnitudeSquared) {
float xhalf;
float temp;
long i;
// magic follows:
temp = magnitudeSquared;
xhalf = 0.5f*temp;
i = *(long*)&temp;
i = 0x5f3759df - (i>>1);
temp = *(float*)&i;
temp = temp*(1.5f - xhalf*temp*temp);
// temp now contains the 1/sqrt(magnitudeSquared)
return temp;
}
Definitely works on the computer:
5629.000: InvSqrt 0.013318; 1/sqrt 0.013329
281.0000: InvSqrt 0.059639; 1/sqrt 0.059655
28.00000: InvSqrt 0.188722; 1/sqrt 0.188982
6.000000: InvSqrt 0.407681; 1/sqrt 0.408248
4.000000: InvSqrt 0.499154; 1/sqrt 0.500000
2.017857: InvSqrt 0.703756; 1/sqrt 0.703971
0.250000: InvSqrt 1.996614; 1/sqrt 2.000000
0.166667: InvSqrt 2.445322; 1/sqrt 2.449490
0.000000: InvSqrt 19817753709685768192; 1/sqrt inf
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.