Page 1 of 1
making .elf out of .o using GCC?
Posted: Tue Feb 24, 2004 5:39 am
by 0xFF
Hi, I'm new to GCC for the ps2.
I was wondering if anyone could tell me how to convert .o files into .elf files using GCC. I'm using the ps2Dev envirmonment variables (That big 30 MB installation version).
I have a simple program with nothing in it (int main(void){}) called main.c
I compile it using: ee-gcc -Tc:\ps2dev\ps2lib\ee\startup\linkfile -o main.o main.c
Now I've got my object file, HOW do I turn it into an .elf file?
Thanks in advance and sorry for the very simple question.
Posted: Tue Feb 24, 2004 7:12 am
by mrbrown
Short answer: read Makefile.eeglobal in ps2lib. You might have to read up on GNU make and Makefiles also, but it'll be worth it.
still stuck
Posted: Tue Feb 24, 2004 7:52 am
by Guest
Thanks for the help mr brown. But I've read all the make files and still I can't convert object files into .elf files.
Can somebody please help me convert .o files into .elf files using ee-gcc?
Thanks.
Posted: Tue Feb 24, 2004 7:58 am
by 0xFF
Sorry, I didn't log in, but that is my post above.
Seriously guys, help will be very appreciated!
Posted: Tue Feb 24, 2004 12:25 pm
by ooPo
ee-gcc -Tc:\ps2dev\ps2lib\ee\startup\linkfile -o main.elf main.c
Posted: Wed Feb 25, 2004 4:09 am
by Guest
YEAAAAAAAAASSSSSS. Thanks Oopo. You're the man!
Posted: Wed Feb 25, 2004 4:32 am
by ooPo
You had an elf file the whole time. You were just telling gcc to output as a file called main.o. :)
OT: ELF
Posted: Wed Feb 25, 2004 7:55 am
by mharris
And, strictly speaking, an object file (".o file") is "an elf file" too. It's an ELF relocatable, but it's not an ELF executable (which is what you wanted).
The ELF format (OK, this is redundant, since ELF stands for "Executable and Linking Format") is just an object container -- in addition to executable files and relocatable files, there are also shared libraries and probably other stuff too. Elf is a very nice container, as it's completely architecture-neutral; one file format for lots of things (exec, reloc, so), and lots of architecures (mips, x86, m68k, etc.) in both little-endian and big-endian format. Much nicer than the so-called "portable executable" that windows uses...
[I'm being pedantic here, of course, since everyone knows that in ps2dev parlance, "an .elf file" is generally taken to mean "A staticly-linked MIPS-5900 little-endian executable ELF file."]
Posted: Wed Feb 25, 2004 9:15 am
by Guest
Thanks oopo, and mharris for being so imformative.
I just have one last question :?
Does anybody have any "single-line" code that I could use to test an .elf file on a ps2? This code be anything; it could just draw a block on the screen.
For example:
int main(void)
{
//insert single code function here!
}
Thanks everybody. :wink:
Posted: Wed Feb 25, 2004 9:17 am
by 0xFF
Damn It. I keep on forgetting to log in! Sorry that is my post directly above.
Posted: Wed Feb 25, 2004 9:39 am
by mharris
There is no "hello world" for the PS2...
IMHO, your best bet would be to get one of
dreamtime's (and others') tutorials. All you need are the .elf files ;-P but the sources are worth looking at too, as they can show you a lot of the basics of PS2 development. dreamtime uses his own 2D graphics packages (rather than some of the libraries which have become available since he made the tuts); this can be good and bad -- it will help you understand the nuts and bolts of the GS and GIF, but the barrier to entry is pretty high (i.e., you'd have to some work if you wanted to add 3D, backface culling, etc.)
Any of the entries at
thethirdcreation.net competitions would be something else to try -- they'll give you a good idea of what people are doing now, but the code is far more complicated in most cases.
Posted: Wed Feb 25, 2004 9:47 am
by Guest
thanks for the wake-up call. I'll get to reading those tutorials by dreamtime.
Posted: Wed Feb 25, 2004 11:00 am
by mrbrown
Actually, if you use ps2lib there is "hello world", see the hello example in ps2lib/ee/samples/hello :).
Posted: Wed Feb 25, 2004 11:13 pm
by Guest
Spot on mrbrown! :D
I found the Hello world sample, albeit I can't get it to compile using the makefile.
Please consider the following question as an extension of my last question, making this question, the very last silly question that I've asked.
How do you make the hello world sample using the makefile and make.exe?
I've got this far:
make -f "c:\ps2dev\ps2lib\ee\samples\hello\makefile" all
then I get this error:
MAKE: *** No rule to make target `hello.o', needed by `hello.elf'. Stop.
My hello world makefile looks like this:
EE_BIN = hello.elf
EE_OBJS = hello.o
all: $(EE_BIN)
clean:
ee-gcc -o *.elf *.c
include C:\ps2dev\ps2lib\ee\samples\hello\Makefile.pref
include C:\ps2dev\ps2lib\ee\samples\hello\Makefile.eeglobal
Thanks guys!
Posted: Wed Feb 25, 2004 11:19 pm
by 0xFF
Sorry I forgot to login (again). That is my post above.
I must remember to execute the following code each time I use this forum:
unit32 DumbAssUser0xFF = 0x00001000;
TCHAR mental_note = "REMEMBER TO LOGIN!";
DMATransfer(DumbAssUser0xFF, mental_note); :wink:
Posted: Wed Feb 25, 2004 11:21 pm
by pixel
Change to the "hello" directory instead of making it from the very outside of the building tree.
And for the forum, when you login, you have the little nifty checkbox "Remember me".
Posted: Wed Feb 25, 2004 11:43 pm
by 0xFF
Thanks pixel, but there are still some errors when I run make.exe from the same directory as the hello sample.
When I compile it from the "hello" directory, I get this:
C:\ps2dev\ps2lib\ee\samples\hello>make
ee-gcc -D_EE -fshort-double -O2 -G0 -c -Wall -Ic:/ps2dev/PS2LIB/ee/include -Ic:/
ps2dev/PS2LIB/common/include -I. hello.c -o hello.o
MAKE: ee-gcc: Command not found
MAKE: *** [hello.o] Error 127
The hello makefile looks like this:
EE_BIN = hello.elf
EE_OBJS = hello.o
all: $(EE_BIN)
clean:
rm -f *.elf *.o *.a
include ..\..\..\Makefile.pref
include ..\..\..\Makefile.eeglobal
I'm stumped for answers, please help.
Posted: Thu Feb 26, 2004 12:08 am
by pixel
Your environment (read, the PATH variable) is not correct. Set it so it includes the path to your ee-gcc.exe file.
Posted: Thu Feb 26, 2004 12:33 am
by 0xFF
Thanks a MILLION pixel for sticking with me.
I finally got the sample working (and appened to an infinite loop so I could see "Hello World" on the screen)
I owe you one.
If you need any favours, I'll be glad to help. :D
Posted: Thu Feb 26, 2004 1:30 am
by mrbrown
I need somebody whacked ... this so-called Canadian genius who goes by the name ooPo "The Fixer".
Then fly over to Sweden and off blackdroid "The MIA".
:P