SifLoadModule...

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

Moderators: cheriff, Herben

Post Reply
LBGSHI
Posts: 136
Joined: Mon Aug 07, 2006 5:56 am
Contact:

SifLoadModule...

Post 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?
I may be lazy, but I can...zzzZZZzzzZZZzzz...
User avatar
Lukasz
Posts: 248
Joined: Mon Jan 19, 2004 8:37 pm
Location: Denmark
Contact:

Post 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.
LBGSHI
Posts: 136
Joined: Mon Aug 07, 2006 5:56 am
Contact:

Post 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...
I may be lazy, but I can...zzzZZZzzzZZZzzz...
LBGSHI
Posts: 136
Joined: Mon Aug 07, 2006 5:56 am
Contact:

Post 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...
I may be lazy, but I can...zzzZZZzzzZZZzzz...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post 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.
LBGSHI
Posts: 136
Joined: Mon Aug 07, 2006 5:56 am
Contact:

Post 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.
I may be lazy, but I can...zzzZZZzzzZZZzzz...
User avatar
Lukasz
Posts: 248
Joined: Mon Jan 19, 2004 8:37 pm
Location: Denmark
Contact:

Post 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.
LBGSHI
Posts: 136
Joined: Mon Aug 07, 2006 5:56 am
Contact:

Post 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.
I may be lazy, but I can...zzzZZZzzzZZZzzz...
User avatar
Lukasz
Posts: 248
Joined: Mon Jan 19, 2004 8:37 pm
Location: Denmark
Contact:

Post 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.
LBGSHI
Posts: 136
Joined: Mon Aug 07, 2006 5:56 am
Contact:

Post 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 :)
I may be lazy, but I can...zzzZZZzzzZZZzzz...
LBGSHI
Posts: 136
Joined: Mon Aug 07, 2006 5:56 am
Contact:

Post 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 :)
I may be lazy, but I can...zzzZZZzzzZZZzzz...
Post Reply