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 

gslib simple build issue

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



Joined: 19 May 2004
Posts: 246
Location: Melbourne, Australia

PostPosted: Sat Nov 20, 2004 6:02 pm    Post subject: gslib simple build issue Reply with quote

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


Joined: 17 Jan 2004
Posts: 989

PostPosted: Sat Nov 20, 2004 6:09 pm    Post subject: Reply with quote

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



Joined: 19 May 2004
Posts: 246
Location: Melbourne, Australia

PostPosted: Sat Nov 20, 2004 6:24 pm    Post subject: Reply with quote

Adding 'kernel' again I get:
Code:
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
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sat Nov 20, 2004 11:22 pm    Post subject: Reply with quote

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



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sun Nov 21, 2004 1:25 am    Post subject: Reply with quote

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



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sun Nov 21, 2004 3:07 am    Post subject: Reply with quote

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



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sun Nov 21, 2004 3:37 am    Post subject: Reply with quote

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



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sun Nov 21, 2004 3:39 am    Post subject: Reply with quote

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



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sun Nov 21, 2004 5:37 am    Post subject: Reply with quote

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



Joined: 19 May 2004
Posts: 246
Location: Melbourne, Australia

PostPosted: Sun Nov 21, 2004 4:38 pm    Post subject: Reply with quote

pixel wrote:
Your link order is all wrong.

Do it this way:


-lgs -lc -lkernel -lc -lsyscall


Sweet. That worked, thanks.
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Mon Nov 22, 2004 10:44 pm    Post subject: Reply with quote

Okay, so...

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

Now, about cyclic dependancy, libkernel depends on:
Code:
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:
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:
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.
Back to top
View user's profile Send private message
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