Page 1 of 1

A seemingly simple problem

Posted: Mon Mar 06, 2006 5:31 am
by Apollo
I see under ps2dev/ee/ee/include that there is a math.h file, but when I include this and try to use the sin and cos functions I get this error.

Code: Select all

obj/spiral.o(.text+0x90): In function `spiral':
spiral.c: undefined reference to `litodp'
obj/spiral.o(.text+0x98):spiral.c: undefined reference to `cos'
obj/spiral.o(.text+0xa0):spiral.c: undefined reference to `dptofp'
obj/spiral.o(.text+0xac):spiral.c: undefined reference to `litodp'
obj/spiral.o(.text+0xb4):spiral.c: undefined reference to `sin'
obj/spiral.o(.text+0xbc):spiral.c: undefined reference to `dptofp'
collect2: ld returned 1 exit status
make: *** [spiral.elf] Error 1
I'm new to the ps2 and all I am making is a simple rotating hypnotic spiral. Any ideas why the functions won't work?

Posted: Mon Mar 06, 2006 7:01 am
by Drakonite
You need to link with libm.

In other words, you need to add -lm to the EE_LIBS line the makefile.

Posted: Tue Mar 07, 2006 12:49 pm
by Apollo
That brought about a ton of more errors. I am using the binary sdk of the website. I'm going to download the cygwin toolchain tonight and maybe that will help. Thanks for the response.

Posted: Tue Mar 07, 2006 12:53 pm
by Drakonite
Linking order DOES matter

Posted: Wed Mar 08, 2006 7:38 am
by Apollo
Is this correct?

Code: Select all

spiral.elf: $(C_OBJ) $(S_OBJ)
	@echo "-------------------------------------------------"
	$(CC) $(CFLAGS) -Tlinkfile -o spiral.elf $(C_OBJ) $(S_OBJ) -lm -Wl,-Map,spiral.map

Posted: Wed Mar 08, 2006 9:25 am
by Drakonite
Eww.. you might want to look at the sample makefiles... There should be numerous libraries being linked, and I don't see where any of them are being added...

Posted: Wed Mar 08, 2006 11:03 am
by Apollo
I'm going off of dreamtime's demos. I'll try to look at other examples.

Posted: Wed Mar 08, 2006 2:41 pm
by Apollo
Any hints would be greatly appreciated though.

Posted: Wed Mar 08, 2006 3:10 pm
by Drakonite
I'm using a modified version of the sample makefiles included with ps2sdk.

You should probably have something like '-lm -lc -lkernel -lsyscall -lc'

Posted: Thu Mar 09, 2006 2:11 am
by jbit
By the way, libmf (part of ps2sdk) is supposed to be faster than libm (part of newlib), so you might want to use that.

Posted: Thu Mar 09, 2006 4:09 am
by evilo
duh... I wasn't aware of that !! I MUST test it ASAP !

thanks for the tip :)