making .elf out of .o using GCC?

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

Moderators: cheriff, Herben

Post Reply
0xFF
Posts: 6
Joined: Tue Feb 24, 2004 5:30 am
Location: England
Contact:

making .elf out of .o using GCC?

Post 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.
my business site: http://www.codebytesdev.dynip.com
(brand spanking new)
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post 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.
Guest

still stuck

Post 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.
0xFF
Posts: 6
Joined: Tue Feb 24, 2004 5:30 am
Location: England
Contact:

Post by 0xFF »

Sorry, I didn't log in, but that is my post above.

Seriously guys, help will be very appreciated!
my business site: http://www.codebytesdev.dynip.com
(brand spanking new)
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

ee-gcc -Tc:\ps2dev\ps2lib\ee\startup\linkfile -o main.elf main.c
Guest

Post by Guest »

YEAAAAAAAAASSSSSS. Thanks Oopo. You're the man!
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

You had an elf file the whole time. You were just telling gcc to output as a file called main.o. :)
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

OT: ELF

Post 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."]
Guest

Post 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:
0xFF
Posts: 6
Joined: Tue Feb 24, 2004 5:30 am
Location: England
Contact:

Post by 0xFF »

Damn It. I keep on forgetting to log in! Sorry that is my post directly above.
my business site: http://www.codebytesdev.dynip.com
(brand spanking new)
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

Post 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.
Guest

Post by Guest »

thanks for the wake-up call. I'll get to reading those tutorials by dreamtime.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Actually, if you use ps2lib there is "hello world", see the hello example in ps2lib/ee/samples/hello :).
Guest

Post 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!
0xFF
Posts: 6
Joined: Tue Feb 24, 2004 5:30 am
Location: England
Contact:

Post 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:
my business site: http://www.codebytesdev.dynip.com
(brand spanking new)
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post 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".
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.
0xFF
Posts: 6
Joined: Tue Feb 24, 2004 5:30 am
Location: England
Contact:

Post 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.
my business site: http://www.codebytesdev.dynip.com
(brand spanking new)
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Your environment (read, the PATH variable) is not correct. Set it so it includes the path to your ee-gcc.exe file.
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.
0xFF
Posts: 6
Joined: Tue Feb 24, 2004 5:30 am
Location: England
Contact:

Post 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
my business site: http://www.codebytesdev.dynip.com
(brand spanking new)
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post 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
Post Reply