A seemingly simple problem

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
Apollo
Posts: 10
Joined: Sun Mar 05, 2006 3:19 am

A seemingly simple problem

Post 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?
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

You need to link with libm.

In other words, you need to add -lm to the EE_LIBS line the makefile.
Shoot Pixels Not People!
Makeshift Development
Apollo
Posts: 10
Joined: Sun Mar 05, 2006 3:19 am

Post 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.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Linking order DOES matter
Shoot Pixels Not People!
Makeshift Development
Apollo
Posts: 10
Joined: Sun Mar 05, 2006 3:19 am

Post 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
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post 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...
Shoot Pixels Not People!
Makeshift Development
Apollo
Posts: 10
Joined: Sun Mar 05, 2006 3:19 am

Post by Apollo »

I'm going off of dreamtime's demos. I'll try to look at other examples.
Apollo
Posts: 10
Joined: Sun Mar 05, 2006 3:19 am

Post by Apollo »

Any hints would be greatly appreciated though.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post 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'
Shoot Pixels Not People!
Makeshift Development
User avatar
jbit
Site Admin
Posts: 293
Joined: Sat May 28, 2005 3:11 am
Location: København, Danmark
Contact:

Post 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.
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

duh... I wasn't aware of that !! I MUST test it ASAP !

thanks for the tip :)
Post Reply