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

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

Moderators: cheriff, Herben

Post Reply
Leo
Posts: 3
Joined: Tue May 23, 2006 11:48 pm

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

Post by Leo »

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.
Leo
Posts: 3
Joined: Tue May 23, 2006 11:48 pm

Post by Leo »

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

Post by Drakonite »

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
Leo
Posts: 3
Joined: Tue May 23, 2006 11:48 pm

Post by Leo »

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

Post by Drakonite »

libdebug is part of ps2sdk, if you don't have it then your install is broken.
Shoot Pixels Not People!
Makeshift Development
Neovanglist
Site Admin
Posts: 72
Joined: Sat May 22, 2004 9:29 pm
Location: Copenhagen, Denmark
Contact:

Post by Neovanglist »

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
Post Reply