#900 - punchy - Sun Jan 12, 2003 12:32 am
Anyone have any ideas why linking in the math lib gives a lot of errors like this:
"/gcc-3.0.2/newlib/libm/math/s_cos.c:67: undefined reference to `__subdf3'"
I'm trying to use sin/cos. Is my install missing something?
Thanks.
#903 - Costis - Sun Jan 12, 2003 12:51 am
Hi,
Try placing the "-lm" flag in your make file where you run the "ld" linker program.
Costis
#907 - punchy - Sun Jan 12, 2003 1:32 am
Yeah, I already have the lm flag to link-in the math lib. The errors i'm getting :
libm/math/e_rem_pio2.c:153: undefined reference to `__subdf3'
gcc-3.0.2/newlib/libm/math/e_rem_pio2.c:175: undefined reference to `__muldf3
and so forth, seem to suggest that the math lib is looking for a bunch of definitions it can find.
Any other ideas?
Thanks.
#1005 - Quirky - Mon Jan 13, 2003 9:31 am
Are you using devkitadvance? How are you linking the objects? If you use ld then you need to specify a lot more - if you use gcc to link then it will find most of the libraries for you. I remember that being a problem I had. Alterrnatively, the order you soecify the libs in matters, so try changing where lm is in the list - I think it has to be last.
#1272 - punchy - Thu Jan 16, 2003 3:02 am
Hi,
i'm using devkit adv. I'm using vc++ and watzdat's makefile. The linker instructions i'm using are
$(PROJECT).elf : $(O_FILES)
$(CMPDIR)\ld $(LDFLAGS) -o $(PROJECT).elf $(O_FILES) -lstdc++ -lgcc -lc -lm
I'm putting the math lib last, so any other ideas? Can you remember how you resolved the problem?
Thanks.
#1312 - mo - Thu Jan 16, 2003 6:03 pm
I suspect this has something to do with the linker not executing a double pass. Those __subdf3, etc. math routines which the math library is referencing are located in the gcc library.
There's two ways to solve the problem. First, you could just put the math library before the gcc library in the link line.
Code: |
$(CMPDIR)\ld $(LDFLAGS) -o $(PROJECT).elf $(O_FILES) -lstdc++ -lm -lgcc -lc
|
But better yet, just add the -rescan flag to the list of linkers flags, LDFLAGS, and you never need to worry about an ordering problem again, i.e.:
Code: |
ld -L F:\gba\devkitadv\lib\gcc-lib\arm-agb-elf\3.0.2\interwork -L F:\gba\devkitadv\arm-agb-elf\lib\interwork -T LinkScript -rescan -o sprite.elf boot.o crtbegin.o crtend.o main.o -lstdc++ -lgcc -lc -lm
|
#1389 - punchy - Sat Jan 18, 2003 2:52 am
Both work like a charm. Thanks for your help!
#1390 - punchy - Sat Jan 18, 2003 3:01 am
Oh, using GCC to link solves it too.