gslib simple build issue

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

Moderators: cheriff, Herben

Post Reply
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

gslib simple build issue

Post by radad »

Hey guys, I have downloaded the ps2sdk and built and run the samples ok. I then tried the gslib download. I have built the library itself but I am getting stuck on the 'simple' example.

When I build it I get:

Code: Select all

ee-gcc -nostartfiles -Tc:\ps2dev\ps2sdk/ee/startup/linkfile -Lc:\ps2dev\ps2sdk/ee/lib  -L/ps2dev/gslib/lib -L/ps2dev/ee/lib/gcc-lib/ee/3.2.2 -Lc:\ps2dev\ps2sdk\samples/ee/lib -L/ps2dev/ee/ee/lib \
	-o example.elf c:\ps2dev\ps2sdk/ee/startup/crt0.o example.o -lkernel -lsyscall -lc -lsupc++ -lgcc -lgs -lkernel
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::gsPipe[not-in-charge](unsigned)':
gsPipe.o(.text+0x3c): undefined reference to `memalign'
gsPipe.o(.text+0x74): undefined reference to `puts'
gsPipe.o(.text+0x100): undefined reference to `free'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::gsPipe[in-charge](unsigned)':
gsPipe.o(.text+0x14c): undefined reference to `memalign'
gsPipe.o(.text+0x184): undefined reference to `puts'
gsPipe.o(.text+0x210): undefined reference to `free'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::~gsPipe [not-in-charge]()':
gsPipe.o(.text+0x240): undefined reference to `free'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::~gsPipe [in-charge]()':
gsPipe.o(.text+0x270): undefined reference to `free'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::operator=(gsPipe const&)':
gsPipe.o(.text+0x314): undefined reference to `memalign'
gsPipe.o(.text+0x328): undefined reference to `memcpy'
gsPipe.o(.text+0x3a0): undefined reference to `free'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::Flush()':
gsPipe.o(.text+0x48c): undefined reference to `FlushCache'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::FlushInt()':
gsPipe.o(.text+0x504): undefined reference to `iFlushCache'
collect2: ld returned 1 exit status
make: *** [example.elf] Error 1
I think I need to add the 'c' library so I tried it before the 'kernel' library:

Code: Select all

ee-gcc -nostartfiles -Tc:\ps2dev\ps2sdk/ee/startup/linkfile -Lc:\ps2dev\ps2sdk/ee/lib  -L/ps2dev/gslib/lib -L/ps2dev/ee/lib/gcc-lib/ee/3.2.2 -Lc:\ps2dev\ps2sdk\samples/ee/lib -L/ps2dev/ee/ee/lib \
	-o example.elf c:\ps2dev\ps2sdk/ee/startup/crt0.o example.o -lkernel -lsyscall -lc -lsupc++ -lgcc -lgs -lc -lkernel
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::Flush()':
gsPipe.o(.text+0x48c): undefined reference to `FlushCache'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::FlushInt()':
gsPipe.o(.text+0x504): undefined reference to `iFlushCache'
c:\ps2dev\ps2sdk/ee/lib/libc.a(sbrk.o): In function `ps2_sbrk':
src/sbrk.c(.text+0x78): undefined reference to `EndOfHeap'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(fio_write.o): In function `fioWrite':
src/fileio.c(.text+0x40): undefined reference to `WaitSema'
src/fileio.c(.text+0xf8): undefined reference to `SifWriteBackDCache'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifCallRpc.o): In function `SifCallRpc':
src/sifrpc.c(.text+0xc0): undefined reference to `SifWriteBackDCache'
src/sifrpc.c(.text+0xd0): undefined reference to `SifWriteBackDCache'
src/sifrpc.c(.text+0x158): undefined reference to `CreateSema'
src/sifrpc.c(.text+0x19c): undefined reference to `WaitSema'
src/sifrpc.c(.text+0x1a4): undefined reference to `DeleteSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifRpcMain.o): In function `_request_end':
src/sifrpc.c(.text+0x54): undefined reference to `iSignalSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifRpcMain.o): In function `_request_call':
src/sifrpc.c(.text+0x238): undefined reference to `iWakeupThread'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifRpcMain.o): In function `SifInitRpc':
src/sifrpc.c(.text+0x39c): undefined reference to `SifGetReg'
src/sifrpc.c(.text+0x3ec): undefined reference to `SifSetReg'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(fio_main.o): In function `fioInit':
src/fileio.c(.text+0xb8): undefined reference to `CreateSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(fio_main.o): In function `_fio_intr':
src/fileio.c(.text+0xfc): undefined reference to `iSignalSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(fio_main.o): In function `fioSync':
src/fileio.c(.text+0x184): undefined reference to `PollSema'
src/fileio.c(.text+0x194): undefined reference to `SignalSema'
src/fileio.c(.text+0x1c0): undefined reference to `WaitSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(sif_cmd_send.o): In function `_SifSendCmd':
src/sifcmd.c(.text+0xbc): undefined reference to `SifWriteBackDCache'
src/sifcmd.c(.text+0xd4): undefined reference to `iSifSetDma'
src/sifcmd.c(.text+0x10c): undefined reference to `SifSetDma'
src/sifcmd.c(.text+0x120): undefined reference to `SifWriteBackDCache'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(sif_cmd_main.o): In function `SifInitCmd':
src/sifcmd.c(.text+0x118): undefined reference to `FlushCache'
src/sifcmd.c(.text+0x168): undefined reference to `AddDmacHandler'
src/sifcmd.c(.text+0x18c): undefined reference to `SifGetReg'
src/sifcmd.c(.text+0x1a0): undefined reference to `SifGetReg'
src/sifcmd.c(.text+0x1b4): undefined reference to `SifGetReg'
src/sifcmd.c(.text+0x1c8): undefined reference to `SifSetReg'
src/sifcmd.c(.text+0x1d8): undefined reference to `SifSetReg'
src/sifcmd.c(.text+0x23c): undefined reference to `SifSetDChain'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(sif_cmd_main.o): In function `SifExitCmd':
src/sifcmd.c(.text+0x268): undefined reference to `RemoveDmacHandler'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifBindRpc.o): In function `SifBindRpc':
src/sifrpc.c(.text+0xcc): undefined reference to `CreateSema'
src/sifrpc.c(.text+0x110): undefined reference to `WaitSema'
src/sifrpc.c(.text+0x118): undefined reference to `DeleteSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(EnableDmac.o): In function `EnableDmac':
src/glue.c(.text+0x28): undefined reference to `_EnableDmac'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(DisableDmac.o): In function `DisableDmac':
src/glue.c(.text+0x28): undefined reference to `_DisableDmac'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(_sif_cmd_int_handler.o): In function `_SifCmdIntHandler':
src/sifcmd.c(.text+0x68): undefined reference to `iSifSetDChain'
collect2: ld returned 1 exit status
make: *** [example.elf] Error 1
And after the 'kernel' library:

Code: Select all

ee-gcc -nostartfiles -Tc:\ps2dev\ps2sdk/ee/startup/linkfile -Lc:\ps2dev\ps2sdk/ee/lib  -L/ps2dev/gslib/lib -L/ps2dev/ee/lib/gcc-lib/ee/3.2.2 -Lc:\ps2dev\ps2sdk\samples/ee/lib -L/ps2dev/ee/ee/lib \
	-o example.elf c:\ps2dev\ps2sdk/ee/startup/crt0.o example.o -lkernel -lsyscall -lc -lsupc++ -lgcc -lgs -lkernel -lc
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::Flush()':
gsPipe.o(.text+0x48c): undefined reference to `FlushCache'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::FlushInt()':
gsPipe.o(.text+0x504): undefined reference to `iFlushCache'
c:\ps2dev\ps2sdk/ee/lib/libc.a(puts.o): In function `puts':
src/xprintf.c(.text+0x24): undefined reference to `fioWrite'
c:\ps2dev\ps2sdk/ee/lib/libc.a(sbrk.o): In function `ps2_sbrk':
src/sbrk.c(.text+0x78): undefined reference to `EndOfHeap'
src/sbrk.c(.text+0xa8): undefined reference to `EIntr'
src/sbrk.c(.text+0xb8): undefined reference to `DIntr'
c:\ps2dev\ps2sdk/ee/lib/libc.a(putchar.o): In function `putchar':
src/xprintf.c(.text+0x14): undefined reference to `fioWrite'
collect2: ld returned 1 exit status
make: *** [example.elf] Error 1
I seem to be on the right track but even after I add the 'c' library it has link issues with functions that appear to be from the 'kernel' library. Any ideas?
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

add -lkernel again

yes. it's an ugly hell. linking seems to be about the ugliest thing there is right now.. If the order is wrong, it can fail. Sometimes libraries have to be listed multiple times in order for everything to get linked correctly.
Shoot Pixels Not People!
Makeshift Development
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

Adding 'kernel' again I get:

Code: Select all

ee-gcc -nostartfiles -Tc:\ps2dev\ps2sdk/ee/startup/linkfile -Lc:\ps2dev\ps2sdk/ee/lib  -L/ps2dev/gslib/lib -L/ps2dev/ee/lib/gcc-lib/ee/3.2.2 -Lc:\ps2dev\ps2sdk\samples/ee/lib -L/ps2dev/ee/ee/lib \
	-o example.elf c:\ps2dev\ps2sdk/ee/startup/crt0.o example.o -lkernel -lsyscall -lc -lsupc++ -lgcc -lgs -lc -lkernel -lkernel
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::Flush()':
gsPipe.o(.text+0x48c): undefined reference to `FlushCache'
/ps2dev/gslib/lib/libgs.a(gsPipe.o): In function `gsPipe::FlushInt()':
gsPipe.o(.text+0x504): undefined reference to `iFlushCache'
c:\ps2dev\ps2sdk/ee/lib/libc.a(sbrk.o): In function `ps2_sbrk':
src/sbrk.c(.text+0x78): undefined reference to `EndOfHeap'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(fio_write.o): In function `fioWrite':
src/fileio.c(.text+0x40): undefined reference to `WaitSema'
src/fileio.c(.text+0xf8): undefined reference to `SifWriteBackDCache'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifCallRpc.o): In function `SifCallRpc':
src/sifrpc.c(.text+0xc0): undefined reference to `SifWriteBackDCache'
src/sifrpc.c(.text+0xd0): undefined reference to `SifWriteBackDCache'
src/sifrpc.c(.text+0x158): undefined reference to `CreateSema'
src/sifrpc.c(.text+0x19c): undefined reference to `WaitSema'
src/sifrpc.c(.text+0x1a4): undefined reference to `DeleteSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifRpcMain.o): In function `_request_end':
src/sifrpc.c(.text+0x54): undefined reference to `iSignalSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifRpcMain.o): In function `_request_call':
src/sifrpc.c(.text+0x238): undefined reference to `iWakeupThread'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifRpcMain.o): In function `SifInitRpc':
src/sifrpc.c(.text+0x39c): undefined reference to `SifGetReg'
src/sifrpc.c(.text+0x3ec): undefined reference to `SifSetReg'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(fio_main.o): In function `fioInit':
src/fileio.c(.text+0xb8): undefined reference to `CreateSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(fio_main.o): In function `_fio_intr':
src/fileio.c(.text+0xfc): undefined reference to `iSignalSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(fio_main.o): In function `fioSync':
src/fileio.c(.text+0x184): undefined reference to `PollSema'
src/fileio.c(.text+0x194): undefined reference to `SignalSema'
src/fileio.c(.text+0x1c0): undefined reference to `WaitSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(sif_cmd_send.o): In function `_SifSendCmd':
src/sifcmd.c(.text+0xbc): undefined reference to `SifWriteBackDCache'
src/sifcmd.c(.text+0xd4): undefined reference to `iSifSetDma'
src/sifcmd.c(.text+0x10c): undefined reference to `SifSetDma'
src/sifcmd.c(.text+0x120): undefined reference to `SifWriteBackDCache'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(sif_cmd_main.o): In function `SifInitCmd':
src/sifcmd.c(.text+0x118): undefined reference to `FlushCache'
src/sifcmd.c(.text+0x168): undefined reference to `AddDmacHandler'
src/sifcmd.c(.text+0x18c): undefined reference to `SifGetReg'
src/sifcmd.c(.text+0x1a0): undefined reference to `SifGetReg'
src/sifcmd.c(.text+0x1b4): undefined reference to `SifGetReg'
src/sifcmd.c(.text+0x1c8): undefined reference to `SifSetReg'
src/sifcmd.c(.text+0x1d8): undefined reference to `SifSetReg'
src/sifcmd.c(.text+0x23c): undefined reference to `SifSetDChain'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(sif_cmd_main.o): In function `SifExitCmd':
src/sifcmd.c(.text+0x268): undefined reference to `RemoveDmacHandler'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(SifBindRpc.o): In function `SifBindRpc':
src/sifrpc.c(.text+0xcc): undefined reference to `CreateSema'
src/sifrpc.c(.text+0x110): undefined reference to `WaitSema'
src/sifrpc.c(.text+0x118): undefined reference to `DeleteSema'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(EnableDmac.o): In function `EnableDmac':
src/glue.c(.text+0x28): undefined reference to `_EnableDmac'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(DisableDmac.o): In function `DisableDmac':
src/glue.c(.text+0x28): undefined reference to `_DisableDmac'
c:\ps2dev\ps2sdk/ee/lib/libkernel.a(_sif_cmd_int_handler.o): In function `_SifCmdIntHandler':
src/sifcmd.c(.text+0x68): undefined reference to `iSifSetDChain'
collect2: ld returned 1 exit status
make: *** [example.elf] Error 1
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Your link order is all wrong.

Do it this way:


-lgs -lc -lkernel -lc -lsyscall
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

You guys have seen me rant on this before. Why the ^^%$ did someone split libkernel into libsyscall, when everything was working fine in ps2lib? There are only link errors now because someone screwed up the library dependencies.

At some point you have to make a choice between obsessive abstraction and getting things to work. Move the ANSI C routines that libkernel depends on back into libkernel, or move the libkernel routines that call out to ANSI C routines out of libkernel.

Or go back to using ps2lib, where everything just works.
"He was warned..."
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Huh ? It wasn't your choice to split it ?

Who did that then ? If nobody objects, I'll then put syscall back into kernel, and let syscall.a be a dummy file for compatibility.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Yeah - no, in ps2lib the libsyscall object files were always archived into libkernel. So they existed in both libraries, but no projects out there ever used libsyscall. When ps2sdk was created, someone (don't remember who, not important) moved the syscalls out of libkernel and left the ones in libsyscall, which now meant libsyscall had to be specified on the linker line.

Anyway, that's just background info. But the other part of that is the new ps2sdk libc - now you have a cross dependency between libkernel (loadfile, fileio, and a few others depend on libc) and libc (malloc() and possibly others depend on libkernel). I guess you could make a weak EndOfHeap() for ps2_sbrk() and put that in libc, so that libc can be the last library on the link line. If you go that far, then libc can be added back into GCC for EE, so that it's automatically linked in.

It depends on how flexible you want it.
"He was warned..."
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Oh - you could also just make strncpy(), memcpy() and whatever else libkernel uses from libc inline functions, so that libkernel doesn't depend on libc at all (which IMO is the ideal situation). That was what I had worked for in ps2lib - complete seperation between the two. But I'm not opposed at all to the current libc setup in ps2sdk - just as long as people can link their apps cleanly.
"He was warned..."
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Maybe we should split this thread elsewhere ;)
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

pixel wrote:Your link order is all wrong.

Do it this way:


-lgs -lc -lkernel -lc -lsyscall
Sweet. That worked, thanks.
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Okay, so...

I merged back libsyscall into libkernel, and I created a dummy libsyscall for compatibility.

Now, about cyclic dependancy, libkernel depends on:

Code: Select all

memcpy
memset
strlen
strncpy
vsnprintf
with vsnprintf beeing needed by sio_printf, which I think should be moved to libc, where we already have lots of printf stuff, and libc depends on:

Code: Select all

CreateSema
EndOfHeap
SifBindRpc
SifCallRpc
SifInitRpc
SignalSema
WaitSema
__divdi3
__moddi3
__muldi3
__udivdi3
__umoddi3
dpadd
dpcmp
dpmul
dpsub
dptoli
errno
fioClose
fioLseek
fioOpen
fioRead
fioWrite
litodp
mcFlush
mcSync
sio_putc
vsscanf
(if people are interested, here is how I did... hacky shell code, but prolly working:

Code: Select all

ee-nm libc.a | grep ' U ' | sort -u | awk ' { print $2 } ' | while read s ; do (ee-nm libc.a | grep -v ' U ' | grep ' . ' | grep $s) >& /dev/null || echo $s; done
)

vsscanf is clearly a "bug" (still missing... nobody to write one?), __divdi3, __moddi3, __muldi3, __udivdi3, __umoddi3, dpadd, dpcmp, dpmul, dpsub, dptoli, litodp, are libgcc, mcFlush, mcSync are libmc (duh...) and all the rest (CreateSema, EndOfHeap, SifBindRpc, SifCallRpc, SifInitRpc, SignalSema, WaitSema , errno, fioClose, fioLseek, fioOpen, fioRead, fioWrite, sio_putc) belongs to libkernel.

So, I'll break the cycle by moving sio_printf to xprintf.c inside libc, and by adding weak symbols for memcpy, memset, strlen and strncpy in libkernel as mrbrown suggested.

Comment anyone ?
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Post Reply