forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A seemingly simple problem

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
Apollo



Joined: 05 Mar 2006
Posts: 10

PostPosted: Mon Mar 06, 2006 5:31 am    Post subject: A seemingly simple problem Reply with quote

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:
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?
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon Mar 06, 2006 7:01 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Apollo



Joined: 05 Mar 2006
Posts: 10

PostPosted: Tue Mar 07, 2006 12:49 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Tue Mar 07, 2006 12:53 pm    Post subject: Reply with quote

Linking order DOES matter
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
Apollo



Joined: 05 Mar 2006
Posts: 10

PostPosted: Wed Mar 08, 2006 7:38 am    Post subject: Reply with quote

Is this correct?

Code:
spiral.elf: $(C_OBJ) $(S_OBJ)
   @echo "-------------------------------------------------"
   $(CC) $(CFLAGS) -Tlinkfile -o spiral.elf $(C_OBJ) $(S_OBJ) -lm -Wl,-Map,spiral.map
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Wed Mar 08, 2006 9:25 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Apollo



Joined: 05 Mar 2006
Posts: 10

PostPosted: Wed Mar 08, 2006 11:03 am    Post subject: Reply with quote

I'm going off of dreamtime's demos. I'll try to look at other examples.
Back to top
View user's profile Send private message
Apollo



Joined: 05 Mar 2006
Posts: 10

PostPosted: Wed Mar 08, 2006 2:41 pm    Post subject: Reply with quote

Any hints would be greatly appreciated though.
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Wed Mar 08, 2006 3:10 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
jbit
Site Admin


Joined: 28 May 2005
Posts: 293
Location: København, Danmark

PostPosted: Thu Mar 09, 2006 2:11 am    Post subject: Reply with quote

By the way, libmf (part of ps2sdk) is supposed to be faster than libm (part of newlib), so you might want to use that.
Back to top
View user's profile Send private message Visit poster's website
evilo



Joined: 22 Apr 2004
Posts: 230

PostPosted: Thu Mar 09, 2006 4:09 am    Post subject: Reply with quote

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

thanks for the tip :)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group