Page 1 of 1
Why does this make file not work?
Posted: Mon Jul 03, 2006 3:23 am
by Kojima
Can anyone spot why this is ignoring the EE_LIBS line? It's definitely ignoring because I entered some made up name and it doesn't flag an error.
I'm trying to add the standard C lib so I can use rand() on the second tutorial.
-----------
#----------------------------------------------------------------------------
# File: Makefile
# Author: Tony Saveski,
[email protected]
#----------------------------------------------------------------------------
CC=ee-gcc
AS=ee-as
LD=ee-elf-ld
BMP2C=bmp2c
OBJ_DIR = obj
BMP_DIR = resources
EE_INCS += -I$(PS2SDK)/ee/include -I$(PS2SDK)/ee/dma/include -I$(GCCLIB)/include -I$(PS2GDB)/ee
EE_LIBS += -lgcc -lm -lkernel -lc -lsrrscall -ldebug -lpad
CFLAGS = -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE
BMP_SRC = ff.c
C_SRC = g2.c demo2a.c $(BMP_SRC)
S_SRC = crt0.s ps2_asm.s dma_asm.s gs_asm.s
C_OBJ = $(addprefix $(OBJ_DIR)/, $(C_SRC:.c=.o))
S_OBJ = $(addprefix $(OBJ_DIR)/, $(S_SRC:.s=.o))
demo1.elf: $(C_OBJ) $(S_OBJ)
@echo "-------------------------------------------------"
$(CC) $(CFLAGS) -Tlinkfile -o demo2a.elf $(C_OBJ) $(S_OBJ) -Wl,-Map,demo2a.map
$(OBJ_DIR)/%.o: %.c
@echo "-------------------------------------------------"
$(CC) -c $(CFLAGS) $< -o $@
$(OBJ_DIR)/%.o: %.s
@echo "-------------------------------------------------"
$(CC) -xassembler-with-cpp -c $(CFLAGS) $< -o $@
%.c: $(BMP_DIR)/%.bmp
@echo "-------------------------------------------------"
$(BMP2C) $< $(*F) > $@
clean:
rm -f $(C_OBJ) $(S_OBJ) *.map *.elf $(BMP_SRC)
ff.c: $(BMP_DIR)/ff.bmp
Posted: Mon Jul 03, 2006 4:21 am
by Drakonite
EE_LIBS is part of the makefile template files (makefile.eeglobal, etc),and you aren't using them, you are just writing all your own rules... so of course it won't work.
Posted: Mon Jul 03, 2006 4:26 am
by evilo
furthermore, you should check/use the makefile samples from the SDK, those ones are quite old ;)
Posted: Mon Jul 03, 2006 4:36 am
by Kojima
It won't compile with the sdk makefiles. I don't get it, I've looked through the ps2 sdk samples and not a single line (that I saw) actually invokes EE_LIBS etc.
How much work would it be to add lib support to the above makefile?
Posted: Mon Jul 03, 2006 9:18 am
by evilo
usr\local\ps2dev\sdk\samples\Makefile.eeglobal
Code: Select all
$(EE_BIN) : $(EE_OBJS) $(PS2SDK)/ee/startup/crt0.o
$(EE_CC) -mno-crt0 -T$(PS2SDK)/ee/startup/linkfile $(EE_LDFLAGS) \
-o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(EE_OBJS) $(EE_LIBS)
-o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(EE_OBJS)
$(EE_LIBS)
hmm .... did you say something ??
:) :) :) :)
Posted: Mon Jul 03, 2006 3:19 pm
by Kojima
You just made a very powerful enemy my friend.
:)
Thanks.
Posted: Mon Jul 03, 2006 4:35 pm
by evilo
perfect :)
anyway, I hope to play your ps2 pong very soon now !
Posted: Mon Jul 03, 2006 5:33 pm
by Kojima
You could play it now if I had any ftp space. My isp despite being one of the biggest companies in the uk(BT) are too cheap to give any for free.
I'll try looking for a free provider though.
Posted: Mon Jul 03, 2006 5:37 pm
by Kojima
Man, I'm not having any luck with this makefile. If it's not too much trouble, could someone modify the one i posted up above to load libs please? I just don't know what to do.
Posted: Mon Jul 03, 2006 7:30 pm
by Kojima
I managed it. I don't know how, perhaps voodoo magic, but its working now.
-Edit- Spoke too soon, although it works fine for C, my attempts to convert to C++ have almost worked but not quite,
it now fails, complaining about a missing strlen def. I've done the Extern "C" thing to all my sources but it's not working.
Here's the error,
Code: Select all
C:\ps2dev\ps2sdk\ports\ps2tut_02a>make
-------------------------------------------------
ee-gcc -xassembler-with-cpp -c -Wall -W -EL -G0 -O0 -DPS2_EE ps2_asm.s -o obj/
ps2_asm.o
-------------------------------------------------
ee-gcc -xassembler-with-cpp -c -Wall -W -EL -G0 -O0 -DPS2_EE dma_asm.s -o obj/
dma_asm.o
-------------------------------------------------
ee-gcc -xassembler-with-cpp -c -Wall -W -EL -G0 -O0 -DPS2_EE gs_asm.s -o obj/g
s_asm.o
-------------------------------------------------
ee-gcc -Wall -W -EL -G0 -O0 -DPS2_EE -Tlinkfile -LC:/ps2dev/ps2sdk/ee/lib -o
demo2a.elf obj/g2.o obj/demo2a.o obj/ps2_asm.o obj/dma_asm.o obj/gs_asm.o -lc -l
gcc -lm -lstdc++ -lsyscall -lc -lkernel -lc -lc -lc -Wl,-Map,demo2a.map
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/libgcc.a(unwind-dw2.o)(.text+0
x388): In function `extract_cie_info':
../../gcc/unwind-dw2.c:226: undefined reference to `strlen'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/libgcc.a(unwind-dw2-fde.o)(.te
xt+0x5d4): In function `get_cie_encoding':
../../gcc/unwind-dw2-fde.c:271: undefined reference to `strlen'
collect2: ld returned 1 exit status
make: *** [demo1.elf] Error 1
C:\ps2dev\ps2sdk\ports\ps2tut_02a>
Here's the makefile as is,
Code: Select all
#----------------------------------------------------------------------------
# File: Makefile
# Author: Tony Saveski, [email protected]
#----------------------------------------------------------------------------
CC=ee-gcc
AS=ee-as
LD=ee-elf-ld
BMP2C=bmp2c
OBJ_DIR = obj
BMP_DIR = resources
EE_INCS += -I$(PS2SDK)/ee/include -I$(PS2SDK)/ee/dma/include -I$(GCCLIB)/include -I$(PS2GDB)/ee
EE_LIBS += -lc -lgcc -lm -lstdc++ -lsyscall
EE_LDFLAGS := -L$(PS2SDK)/ee/lib $(EE_LDFLAGS)
CFLAGS = -Wall -W -EL -G0 -O0 -DPS2_EE
EE_LIBS += -lc -lkernel -lc -lc -lc
C_SRC = g2.cc demo2a.cc
S_SRC = ps2_asm.s dma_asm.s gs_asm.s
C_OBJ = $(addprefix $(OBJ_DIR)/, $(C_SRC:.cc=.o))
S_OBJ = $(addprefix $(OBJ_DIR)/, $(S_SRC:.s=.o))
demo1.elf: $(C_OBJ) $(S_OBJ) $(PS2SDK)/ee/startup/linkfile
@echo "-------------------------------------------------"
$(CC) $(CFLAGS) -Tlinkfile $(EE_LDFLAGS)-o demo2a.elf $(C_OBJ) $(S_OBJ) $(EE_LIBS) -Wl,-Map,demo2a.map
$(OBJ_DIR)/%.o: %.cc
@echo "-------------------------------------------------"
$(CC) -c $(CFLAGS) $< -o $@
$(OBJ_DIR)/%.o: %.s
@echo "-------------------------------------------------"
$(CC) -xassembler-with-cpp -c $(CFLAGS) $< -o $@
%.c: $(BMP_DIR)/%.bmp
@echo "-------------------------------------------------"
$(BMP2C) $< $(*F) > $@
clean:
rm -f $(C_OBJ) $(S_OBJ) *.map *.elf
Is it a missing lib?
Posted: Mon Jul 03, 2006 8:34 pm
by Kojima
Fixed it, i had to order the libs, moving stdc to the second lib like so,
-lc -lstdc++ -lgcc -lm -lsyscall
in case anyone else runs into this problem.
-edit- well spoke too soon again, it compiles run but ps2link just says 'could not execute file host:demo20a.elf"
I opened up irlink and it seems to transfer about 30% of the file before aborting.
Any ideas why?
here's the current make file,
Code: Select all
#----------------------------------------------------------------------------
# File: Makefile
# Author: Tony Saveski, [email protected]
#----------------------------------------------------------------------------
CC=ee-gcc
AS=ee-as
LD=ee-elf-ld
BMP2C=bmp2c
OBJ_DIR = obj
BMP_DIR = resources
EE_INCS += -I$(PS2SDK)/ee/include -I$(PS2SDK)/ee/dma/include -I$(GCCLIB)/include -I$(PS2GDB)/ee
EE_LIBS += -lc -lstdc++ -lgcc -lm -lsyscall
EE_LDFLAGS := -L$(PS2SDK)/ee/lib $(EE_LDFLAGS)
CFLAGS = -Wall -W -EL -G0 -O0 -DPS2_EE
EE_LIBS += -lc -lkernel -lc -lc -lc
C_SRC = g2.cc demo2a.cc
S_SRC = ps2_asm.s dma_asm.s gs_asm.s
C_OBJ = $(addprefix $(OBJ_DIR)/, $(C_SRC:.cc=.o))
S_OBJ = $(addprefix $(OBJ_DIR)/, $(S_SRC:.s=.o))
demo1.elf: $(C_OBJ) $(S_OBJ)
@echo "-------------------------------------------------"
$(CC) $(CFLAGS) -Tlinkfile $(EE_LDFLAGS)-o demo2a.elf $(C_OBJ) $(S_OBJ) $(EE_LIBS) -Wl,-Map,demo2a.map
$(OBJ_DIR)/%.o: %.cc
@echo "-------------------------------------------------"
$(CC) -c $(CFLAGS) $< -o $@
$(OBJ_DIR)/%.o: %.s
@echo "-------------------------------------------------"
$(CC) -xassembler-with-cpp -c $(CFLAGS) $< -o $@
%.c: $(BMP_DIR)/%.bmp
@echo "-------------------------------------------------"
$(BMP2C) $< $(*F) > $@
clean:
rm -f $(C_OBJ) $(S_OBJ) *.map *.elf
-Edit- Tried everything, removed just all compile flags that didn't cause a linker error, and still the same, flat out refuses to run. My pong game still runs fine, BUT once it's failed to load this, I have to do a soft or hard reset for anything else to run.
Any ideas why it's not working?
Posted: Mon Jul 03, 2006 10:37 pm
by evilo
kojima,
please :
1st - don't use irlink, but prefer ps2client
2dn - don't reuse that makefile, and prefer a new one based on the SDK samples
check one of mine (from my smw port)
Code: Select all
# Super Mario War / PS2
#------------------------------------------------------------------
# Copyright 2005 - Olivier "evilo" Biot <[email protected]>
# Released under GNU license
# Review SMW README & LICENSE files for further details.
#------------------------------------------------------------------
# GCC 3.2.2 / PS2SDK 1.2 / GSKIT 0.2 / SDL 0.1
#------------------------------------------------------------------
# Compilation Flags
#
#------------------------------------------------------------------
EE_BIN = smw.elf
EE_LIBS += -L$(PS2SDK)/ports/lib -lsdlmain -lSDL_image -lsdlmixer -lsdl -ljpg -lmc -ldebug
EE_INCS += -I../include -I$(PS2SDK)/ports/include -I$(PS2SDK)/ports/include/zlib -I$(PS2SDK)/ports/include/SDL
EE_CXXFLAGS += -mlong32 -DUSE_ROMFS -DSYS_LITTLE_ENDIAN -DSYS_NEED_ALIGNMENT -DUSE_RWOPS
EE_CFLAGS += -DSYS_LITTLE_ENDIAN -DSYS_NEED_ALIGNMENT
GENROMFS_PATH = ../tools/genromfs
GENROMFS = $(GENROMFS_PATH)/genromfs
EE_OBJS = SFont.o \
eyecandy.o \
gamemodes.o \
gfx.o \
main.o \
map.o \
player.o \
music_player.o \
romdisk.o romfs.o romfs_io.o
romdisk.img:
@echo Creating romdisk..
@$(GENROMFS) -f $@ -d romdisk
romdisk.o: romdisk.img
@$(PS2SDK)/bin/bin2o -a 16 -n romdisk.img romdisk.o romdisk
all: build_romfs $(EE_BIN)
$(EE_STRIP) $(EE_BIN)
build_romfs:
$(MAKE) -C $(GENROMFS_PATH) all
clean:
rm -f -R *.elf $(EE_OBJS) romdisk.img
$(MAKE) -C $(GENROMFS_PATH) clean
run:
ps2client -h 192.168.0.100 execee host:$(EE_BIN)
reset:
ps2client -h 192.168.0.100 reset
include Makefile.pref
include Makefile.eeglobal
good luck !
Posted: Mon Jul 03, 2006 10:45 pm
by Kojima
I am using Ps2Client, I just used irlink to monitor how much of the file was transfered before it failed. IrLink doesn't even work anyway, aside from the transfer monitor.
I did try to make a new make file based on the samples, but it wouldn't compile saying there was no rule for the .o files, when there clearly was.
But shouldn't my one above work? It compiles fine, links fine, just doesn't run? All I did was change from C to C++, as I did with my pong game, and pong runs fine in C++.
No ideas at all how i could fix my one up? I'm learning just by tinkering with the sample makefiles and I understand how it works now, mostly(At least as far as getting something to compile and link goes)
but my knowledge isn't great enough to figure out why a perfectly compiled and link app fails to run.
In the words of Lennon. Help!
:)
Posted: Mon Jul 03, 2006 10:47 pm
by evilo
with the new makefile rules, you must rename the .s to .S :)
Posted: Mon Jul 03, 2006 11:44 pm
by Kojima
There are rules for that in eeglobal too as far as I can see.
I've just tried again, took my pong makefile, ee global and tried to make a new one based on both for the new app, and still it complains 'no rule to make target '/g2.o'
HEre's the main makefile
Code: Select all
# ____ ___ | / _____ _____
# | __ | |___/ | |
# |___| ___| | \ __|__ | gsKit Open Source Project.
# ----------------------------------------------------------------------
# Copyright 2004 - Chris "Neovanglist" Gilbert <[email protected]>
# Licenced under Academic Free License version 2.0
# Review gsKit README & LICENSE files for further details.
#
# examples/basic/Makefile - Makefile for "basic" example.
#
EE_BIN = demo2a.elf
all: $(EE_BIN)
clean:
rm -f *.erl *.o *.a
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
and the modified eeglobal,
Code: Select all
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# $Id: Makefile.eeglobal_sample 1150 2005-06-12 11:42:08Z pixel $
OBJ_DIR = obj
BMP_DIR = resources
EE_INCS += -I$(PS2SDK)/ee/include -I$(PS2SDK)/ee/dma/include -I$(GCCLIB)/include -I$(PS2GDB)/ee
EE_LIBS += -lc -lstdc++ -lgcc -lm -lsyscall
EE_LDFLAGS := -L$(PS2SDK)/ee/lib $(EE_LDFLAGS)
EE_LIBS += -lc -lkernel -lc -lc -lc
C_SRC = g2.cc demo2a.cc
S_SRC = ps2_asm.s dma_asm.s gs_asm.s
C_OBJ = $(addprefix $(OBJ_DIR)/, $(C_SRC:.cc=.o))
S_OBJ = $(addprefix $(OBJ_DIR)/, $(S_SRC:.s=.o))
# Include directories
EE_INCS := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I. $(EE_INCS)
# C compiler flags
EE_CFLAGS := -D_EE -O2 -G0 -Wall $(EE_CFLAGS)
# C++ compiler flags
EE_CXXFLAGS := -D_EE -O2 -G0 -Wall $(EE_CXXFLAGS)
# Linker flags
# Assembler flags
EE_ASFLAGS := -G0 $(EE_ASFLAGS)
# Link with following libraries. This is a special case, and instead of
# allowing the user to override the library order, we always make sure
# libkernel is the last library to be linked.
# Externally defined variables: EE_BIN, EE_OBJS, EE_LIB
# These macros can be used to simplify certain build rules.
EE_C_COMPILE = $(EE_CC) $(EE_CFLAGS) $(EE_INCS)
EE_CXX_COMPILE = $(EE_CXX) $(EE_CXXFLAGS) $(EE_INCS)
%.o : %.c
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
%.o : %.cc
$(EE_CXX) $(EE_CXXFLAGS) $(EE_INCS) -c $< -o $@
%.o : %.cpp
$(EE_CXX) $(EE_CXXFLAGS) $(EE_INCS) -c $< -o $@
%.o : %.S
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
%.o : %.s
$(EE_AS) $(EE_ASFLAGS) $< -o $@
$(EE_BIN) : $(C_OBJ) $(S_OBJ) $(PS2SDK)/ee/startup/crt0.o
$(EE_CC) -mno-crt0 -T$(PS2SDK)/ee/startup/linkfile $(EE_LDFLAGS) \
-o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(C_OBJ) $(S_OBJ) $(EE_LIBS)
$(EE_ERL) : $(EE_OBJS)
$(EE_CC) -mno-crt0 -o $(EE_ERL) $(EE_OBJS) $(EE_CFLAGS) $(EE_LDFLAGS) -Wl,-r
$(EE_STRIP) --strip-unneeded -R .mdebug.eabi64 -R .reginfo -R .comment $(EE_ERL)
$(EE_LIB) : $(EE_OBJS)
$(EE_AR) cru $(EE_LIB) $(EE_OBJS)
Any ideas why this is failing? I don't know what else to try.
I live for the day someone releases a VC like ide for ps2 dev, that generates the makefile for you. :)
Posted: Tue Jul 04, 2006 12:28 am
by Kojima
Well I've managed to get the new makefile compiling and linking just fine. But as before the final elf refuses to run on the ps2.
Code: Select all
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# $Id: Makefile.eeglobal_sample 1150 2005-06-12 11:42:08Z pixel $
CC=ee-gcc
OBJ_DIR = obj
BMP_DIR = resources
EE_INCS += -I$(PS2SDK)/ee/include -I$(PS2SDK)/ee/dma/include -I$(GCCLIB)/include -I$(PS2GDB)/ee
EE_LIBS += -lc -lstdc++ -lgcc -lm -lsyscall
EE_LDFLAGS := -L$(PS2SDK)/ee/lib $(EE_LDFLAGS)
EE_LIBS += -lc -lkernel -lc -lc -lc
C_SRC = demo2a.cc
S_SRC = ps2_asm.s dma_asm.s gs_asm.s
C_OBJ = g2.o demo2a.o
S_OBJ = ps2_asm.o dma_asm.o gs_asm.o
# Include directories
EE_INCS := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I. $(EE_INCS)
# C compiler flags
EE_CFLAGS := -D_EE -O2 -G0 -Wall $(EE_CFLAGS)
# C++ compiler flags
EE_CXXFLAGS := -Wall -W -EL -G0 -O0 -DPS2_EE
# Linker flags
# Assembler flags
EE_ASFLAGS := -G0 $(EE_ASFLAGS)
# Link with following libraries. This is a special case, and instead of
# allowing the user to override the library order, we always make sure
# libkernel is the last library to be linked.
# Externally defined variables: EE_BIN, EE_OBJS, EE_LIB
# These macros can be used to simplify certain build rules.
EE_C_COMPILE = $(EE_CC) $(EE_CFLAGS) $(EE_INCS)
EE_CXX_COMPILE = $(EE_CXX) $(EE_CXXFLAGS) $(EE_INCS)
%.o : %.c
$(CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
%.o : %.cc
$(EE_CXX) $(EE_CXXFLAGS) $(EE_INCS) -c $< -o $@
CFLAGS = -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE
%.o : %.s
$(CC) -xassembler-with-cpp -c $(CFLAGS) $< -o $@
$(EE_BIN) : $(C_OBJ) $(S_OBJ)
$(EE_CC) $(CFLAGS) -mno-crt0 -Tlinkfile $(EE_LDFLAGS) \
-o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(C_OBJ) $(S_OBJ) $(EE_LIBS)
$(EE_LIB) : $(EE_OBJS)
$(EE_AR) cru $(EE_LIB) $(EE_OBJS)
Posted: Tue Jul 04, 2006 12:48 am
by evilo
Seems that uint64 is not recognized..
be sure that g2.c include tamtypes.h
Posted: Tue Jul 04, 2006 12:58 am
by Kojima
I fixed that problem, please check my edited post above, i got the makefile working(The new one) but the resulting elf fails to run still.
Makes. No. Sense.
edit- changed -Tlinkfile to -T$(PS2SDK)/ee/startup/linkfile and now it runs, but immediately after running it throws a EE exception "TLB store exception"
So it appears to be the linkfile is what's causing problems.
Posted: Tue Jul 04, 2006 1:15 am
by Kojima
FIXED! Thanks for all your help e.
turns out the exception was an unrelated mistake in my code, so the linkfile change did fix it afterall. So anyone who uses the tutorials as a base like i have, be sure to change linkfiles if you switch to C++.
Anyway expect LikeAllegro very soon, a old skool 2d library with per pixel fx like lighting etc :)
Posted: Tue Jul 04, 2006 1:34 am
by evilo
Good that you fixed your issue !
concerning LikeAllegro, does it have something to do with Allegro ??
I hope you'll use gsKit as a base instead of the libdream tutorial .... libdream is great to see how the GS is working, but just lacks good performances :)
Posted: Tue Jul 04, 2006 2:36 am
by Kojima
Yeah, kind of like Allegro, Bitmaps etc, but won't be as fleshed out or based on allegro's code.
I will probably use gsKit for my second lib, I'm still learning so I think I'll use the tutorials mini-lib for now.