GP32 math.h


mak

Still Fresh
Joined
Aug 7, 2003
Messages
18
Website
www.maksw.com
I know guys - yet another math thread - I've read up the forums found by searching for math.h and made sure I have linked in -lm, #include <math.h>, removed the -fshort-double switch.

But i still get the following when linking....

e:/sdk/gp32/lib/gcc-lib/arm-agb-elf/3.0.2/../../../../arm-agb-elf/lib/libmaksw.a(gpvector.o): In function `CGPVector::GetMagnitude()':
gpvector.o(.text+0x504): undefined reference to `sqrt'

same for sin, cos, atan, fabs etc...

and I am not interested in fixed point, or lookup tables just now. I want to get the standard lib working.

Rico mentioned in a thread that the math.h is fubar?

Surely someone somewhere has got math.h working and linked?, so that person, pleeeeease help!

(Oh, I am using devkitadvance btw...)
 
Hmm.. i have been using sqrt() atleast..
I'm using gcc 3.2.2, which i have built myself, not that i think it should matter..
I haven't done anything special to get it working..

---
mithris
 
That error message is nothing to do with headers or compiler switches, it's the linker not finding libm.a.

You have said that you've included -lm in your link command, so there's only 2 things I can think of:

1) libm.a is not in the path that the linker is searching for libraries. Check the -L switches on your link command
2) Sometimes, the order of libraries is important. libm is pretty low-level, so (I think) it should be one of the last ones linked (higher-level libraries should be specified first). That is, -lgpstdio ...etc... -lm -lc -lgcc

Could you post your link command / makefile?
 
It may be me, but seeing as this lib is nowt special, and my code uses the other libs with no problems, I do not see how... but I never rule it out ;)
 
libm.a works fine here (again self compiled environment). Just make sure, as said earlier, that linker finds the libm.a and play around with the -lm position during the linking phase. Also if you use CHN's devkitadv package there was some option in gp32.mk, which I can't remember now, that causes problems with trigonometric functions.
 
Nooooooooo :(

Fixed it - Mr. Spiv - your comment "play... with the -lm postion" did the trick.

I did not realise the link order was THAT important sadly.

I was moving it around in my

Code:
STDLIBS= -lc -lg -lstdc++
GPLIBS=-lgpsdk -lgpgraphic -lgpmem -lgpos -lgpstdlib -lgpstdio -lgpsound -lgpfont -lgpg_ex01

part of gp32.mk, no matter where i put it, no joy.

BUT as i have created my own sdk lib, i placed -m AFTER i link in that and as if by magic, linking works.

Seems the -lm has to be the LAST library linked? Ah well, works for me.

Thanks all ;)

PS - I have ONLY just noticed Robsters reply 1 minute before i posted on the 18/09! Darn, if only i had been 10 mins later! :p

Thanks anyways....
 
Back
Top