Page 1 of 1

SifLoadModule...

Posted: Thu Apr 02, 2009 3:09 am
by LBGSHI
Is SifLoadModule defined in LoadFile.h alone, or is there another file I'm overlooking? I'm trying to revamp the old G2 library built by DreamTime, and temporarily using some fairly unorthodox methods to accomplish some testing and R&D (rather than tearing down the entire lib in order to remove the -nostdlib flag, I'm simply sidestepping it altogether for the time being by including requisite files explicitly and directly), but I can't seem to get around the error

"undefined reference to `SifLoadModule'"

...regardless of whether or not I include LoadFile.h.

Any ideas?

Posted: Thu Apr 02, 2009 3:55 am
by Lukasz
The undefined reference is a linker error and not compile error.

So what you are missing is linking with libkernel.a by passing -lkernel parameter to ee-gcc along with the correct path. Which is always done in the prefined Makefile.eeglobal for the PS2SDK samples, by adding -lkernel (libkernel.a) and -lc (libc.a) to the EE_LIBS variables and the correct paths with EE_INCS.

Posted: Thu Apr 02, 2009 9:12 am
by LBGSHI
I see! So, even though I've added the lines

include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal

...to the end of the makefile, it must not be processing them for some reason...

Thanks for the insight. I'll see if I can come up with a resolution, and, even better, if I can figure out why it's failing in the first place...

Posted: Thu Apr 02, 2009 1:50 pm
by LBGSHI
Even forcing those seems to have no effect. Here's my current makefile:

Code: Select all


EE_INCS := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I. $(EE_INCS) -I$(PS2SDK)/ports -I$(PS2SDK)/ports/include
EE_LIBS := -lpadx -lc -lkernel
EE_LDFLAGS := -L$(PS2SDK)/ee/lib $(EE_LDFLAGS)
CFLAGS = -EL -G0 -mips3 -nostdlib -DPS2_EE

C_SRC = gs.c g2.c mdsplash.c splash.c
S_SRC = crt0.s ps2_asm.s dma_asm.s gs_asm.s

C_OBJ = $(addprefix obj/, $(C_SRC:.c=.o))
S_OBJ = $(addprefix obj/, $(S_SRC:.s=.o))

mdsplash.elf: $(C_OBJ) $(S_OBJ)
	@echo "-------------------------------------------------"
	ee-gcc $(CFLAGS) -Tlinkfile $(EE_LDFLAGS) $(EE_LIBS) -o mdsplash.elf $(C_OBJ) $(S_OBJ)

obj/%.o: %.c
	@echo "-------------------------------------------------"
	ee-gcc $&#40;EE_INCS&#41; -c $&#40;CFLAGS&#41; $< -o $@

obj/%.o&#58; %.s
	@echo "-------------------------------------------------"
	ee-gcc -xassembler-with-cpp -c $&#40;CFLAGS&#41; $< -o $@

%.c&#58; resources/%.bmp
	@echo "-------------------------------------------------"
	bmp2c $< $&#40;*F&#41; > $@

clean&#58;
	rm -f $&#40;C_OBJ&#41; $&#40;S_OBJ&#41; *.elf splash.c

splash.c&#58; resources/splash.bmp

Is there anything glaringly amiss? Including or not including makefile.eeglobal and makefile.pref in the normal fashion seems to have no effect, as if the include directive is ignored...

Posted: Thu Apr 02, 2009 4:18 pm
by J.F.
Are you in Windows or linux? The filename is "loadfile.h", not "LoadFile.h", and it DOES make a difference in linux. Remember that case IS significant in linux. Also, look at a sample makefile.

Code: Select all

EE_BIN = pad_example.elf
EE_OBJS = pad.o
EE_LIBS = -lpad -lc

all&#58; $&#40;EE_BIN&#41;

clean&#58;
	rm -f *.elf *.o *.a

include $&#40;PS2SDK&#41;/samples/Makefile.pref
include $&#40;PS2SDK&#41;/samples/Makefile.eeglobal
You may have conflicting lines in your makefile. Remove everything that doesn't correspond to what's in the makefile above.

Posted: Thu Apr 02, 2009 9:29 pm
by LBGSHI
I'm using MinGW, and the file is properly (un)capitalized. Yes, I'm aware of what a standard makefile looks like, and there'd be no problem, if I had the ability to simply "remove everything that doesn't correspond" to one. However, as mentioned, I'm trying to avoid that time-consuming endeavor for the moment...

Thanks very much for the help, though. The effort does not go unappreciated.

Posted: Fri Apr 03, 2009 1:58 am
by Lukasz
Try changing the order of the EE_LIBS:

Code: Select all

EE_LIBS &#58;= -lpadx -lc -lkernel
To something like

Code: Select all

EE_LIBS &#58;= -lkernel -lc -lpadx
or even

Code: Select all

EE_LIBS &#58;= -lkernel -lc -lpadx -lc -lkernel
There is a linker bug which can cause undefined references if the the libs are not specified in a correct order relative to each other.

Posted: Fri Apr 03, 2009 2:07 am
by LBGSHI
I remember reading about that bug, and even seeing it mentioned as the reason for the makefile.eeglobal's forced ordering of some of the libs.

Unfortunately, neither of those made a difference...ack.

Posted: Fri Apr 03, 2009 2:20 am
by Lukasz
Sounds like the bug is in your source, maybe you should post all the files and then we might be able to figure it out.

Posted: Fri Apr 03, 2009 8:25 am
by LBGSHI
There must be, but I sure can't locate it. I'm not really...erm, at liberty to share the entire source, but I would if I could. Thanks for the help, in any case, and wish me luck :)

Posted: Sat Apr 04, 2009 4:22 am
by LBGSHI
Ah, jimmi pointed out the need for $(EE_LDFLAGS) $(EE_LIBS) in my linking statement, and then the final requirement was your suggested re-ordering of the libs, namely the redundant EE_LIBS := -lkernel -lc -lpadx -lc -lkernel

Thanks :)