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 

Link error: 'link' and 'unlink' ???

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



Joined: 23 May 2006
Posts: 3

PostPosted: Wed May 24, 2006 1:22 am    Post subject: Link error: 'link' and 'unlink' ??? Reply with quote

Hello, trying to compile a c++ app, upon link I get the following:

/cygdrive/p/ps2dev/setup/gcc/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libc.a(unlinkr.o)(.text+0x14): In function `_unlink_r':
../../../../../newlib/libc/reent/unlinkr.c:54: undefined reference to `unlink'
/cygdrive/p/ps2dev/setup/gcc/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libc.a(linkr.o)(.text+0x1c): In function `_link_r':
../../../../../newlib/libc/reent/linkr.c:61: undefined reference to `link'


Where are those functions defined?
I am currently including -lc -lkernel -lsyscall in link options.
Also tried adding all them options twice as -lc -lkernel -lsyscall -lc -lkernel -lsyscall .

Thanks.
Back to top
View user's profile Send private message
Leo



Joined: 23 May 2006
Posts: 3

PostPosted: Thu May 25, 2006 3:23 am    Post subject: Reply with quote

I'm trying also to use init_scr() and scr_printf() functions, and gives me the same problem:

../Test.cpp: undefined reference to `init_scr()'
./Test.o(.text+0x8c):../Test.cpp: undefined reference to `scr_printf(char const*, ...)'

Doing an objdump, I've seen these functions are in libkernel, so why does it give me this error?
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Thu May 25, 2006 4:00 am    Post subject: Reply with quote

init_scr and scr_printf are in -ldebug

as for your first post... you said c++? .. try adding -lg after -lc
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
Leo



Joined: 23 May 2006
Posts: 3

PostPosted: Thu May 25, 2006 6:02 pm    Post subject: Reply with quote

My binary sdk doesn't have a libdebug.a, nor a debug.h.
init_scrand scr_printf are declared in kernel.h

Also, adding -lg after -lc (or before that) doesn't seem to work. :(

Something else I could try?


Note: In my binary distro, doing an objdump on kernel shows:

$ ../../../../gcc/ee/bin/ee-objdump.exe -x ../../../../ps2lib/ee/lib/libkernel.a | grep scr_printf
00000328 g F .text 000001dc scr_printf


$ ../../../../gcc/ee/bin/ee-objdump.exe -x libc.a | grep link
linkr.o: file format elf32-littlemips
rw-r--r-- 1000/513 17100 Jun 16 19:15 2004 linkr.o
00000000 g F .text 00000054 _link_r
00000000 *UND* 00000000 link
0000001c R_MIPS_26 link
00000000 *UND* 00000000 _unlink_r
00000008 R_MIPS_26 _unlink_r
00000000 *UND* 00000000 _link_r
00000000 *UND* 00000000 _unlink_r
0000001c R_MIPS_26 _link_r
00000030 R_MIPS_26 _unlink_r
unlinkr.o: file format elf32-littlemips
rw-r--r-- 1000/513 17264 Jun 16 19:15 2004 unlinkr.o
00000000 g F .text 0000004c _unlink_r
00000000 *UND* 00000000 unlink
00000014 R_MIPS_26 unlink
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Thu May 25, 2006 10:22 pm    Post subject: Reply with quote

libdebug is part of ps2sdk, if you don't have it then your install is broken.
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
Neovanglist
Site Admin


Joined: 22 May 2004
Posts: 72
Location: Copenhagen, Denmark

PostPosted: Fri May 26, 2006 1:29 am    Post subject: Reply with quote

People should STOP trying to do the banz0red multiple lib linking order crap.

(Like having -lc -lkernel -lc -lsyscalls -lkernel etc to fix unresolved symbol issues)

The way to resolve this is NOT by putting them over and over, but by using --start-group and --end-group.

For example, in your makefile do:

EE_LIBS = -Xlinker --start-group

EE_LIBS += -lgcc -lm -lgskit -ldmakit -lkernel -lc -lsyscall -ldebug

EE_LIBS += -Xlinker --end-group

Note that each lib is only used one.

Also, the -Xlinker part is VERY important.

If you are linking using GCC and not ld itself, you need -Xlinker to get the --start/end-group flags to the linker itself. Remeber that GCC is a frontend, not the actual workhorse.
_________________
Regards,
Neovanglist
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
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