Stuck with float

Hi all,

I am working on lpc2138.I am using Eclipse for writing my code.I need to do some calculation to read temparature.I am using a float value for my calculation.Eclipse is giving errors like

undefined reference to __floatsidf

undefined reference to __muldf3

undefined reference to __truncdfsf2

undefined reference to __fixunssfsi

I have included <math.h>.How do i link this lib to my code.

I am stuck up here.Please help me to solve this.

Thanks

Gireesh

Hi Gireesh.

To get floating point to work, you need to link in the standard library libgcc.a.

I created a “mini-tutorial” for some readers who contacted me about this; at least it will give you an idea of how I selected and linked in libgcc.a

You can download this short pdf file here (be forewarned that megaupload.com is not exactly a family-friendly site). The name of the pdf file (4 pages) is “Adding Library to Eclipse C.pdf”

www.megaupload.com/?d=F7RSE2YM

I just checked and this short pdf file is still stored on megaupload.com. I also just tested it with a simple floating point operation on my AT91SAM7S256-EK board. The OpenOCD debugger showed that the floating point calculations work OK if you have this library.

Give this a try and let me know how you got along.

Cheers,

Jim Lynch

Hi jim,

Thank you for your reply.

Now its not giving any error.I am testing my code.

And one more quetstion.

Some time it was giving error like libgcc.a uses harware fp some thing like that.Is this libgcc.a is for the pocessors which having harware fp?

thank you

Gireesh

You have to decide whether you use hard- or soft-float when compiling your toolchain. Hard-float is going to work only on processors with a FPU, or on top of an operating system that provides FPU emulation. Soft-float includes library functions for floating point operations, and works on every system, but can’t make use of an FPU on systems that have one.

Regards,

Dominic

hi dominic

Thank you for your reply and advice.At present i am using LPC2138.so harware-FP will not work.So i have to software-fp.

And i have more questiens here…

I am downloading my code on to RAM because of debuging purposes.Using Open-ocd for debugging and amontec jtag.I am running a timer in my application.Till i add this libgcc.a my code was running fine and the timer interrupt was happening the way i did the setup.After i included the lib it started mis behaving.I notieced his kind of situation before also.Those time i did compiling two time after a clean.It solved its own.I configured the timer for IRQ.But when i run it goes to fiq and doing nothing.Where i am doing wrong.Is it because i am running in the ram?

Is it because of bad memory maping?

Some time i feel its not compiling properly.

Thanks

Gireesh