How to compile?

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

Moderators: cheriff, Herben

Post Reply
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

How to compile?

Post by Thanhda »

okay, i've been trying to look around, but i cant seem to find out how to compile my code to an elf file.

I am currently running on Knopixx linux, and was able to get the autobuild install, but i dont know where to go from there. i know in gcc to compile code its

Code: Select all

gcc file.c -o name
if you can just direct me to a tutor that would be great. and yes i have already checked out http://www.oopo.net/consoledev/. all it says is theres an old way to do it, but just use the auto build. i cant seem to find anywhere that teaches how to use gcc or compile ps2 code.
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

use the toolchain.sh script on ooPo's site and run it.
Kung VU
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

If you have already built the toolchain, you can go to /usr/local/ps2dev/ps2sdk/sample/hello and type 'make'. This will build a sample 'hello world' program for you.
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

blackdroid wrote:use the toolchain.sh script on ooPo's site and run it.
buddy, read my post i said i already built it. what do i do next. i'm not a linux user, so i dont know what to do next. btw it says

knoppix@ttyp0[ps2toolchain]$ ./toolchain.sh
bash: ./toolchain.sh: Permission denied

only toolchain-oldiop.sh seems to work. can it still use this one? is this just an older version?
Last edited by Thanhda on Sat Apr 23, 2005 1:58 am, edited 1 time in total.
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

ooPo wrote:If you have already built the toolchain, you can go to /usr/local/ps2dev/ps2sdk/sample/hello and type 'make'. This will build a sample 'hello world' program for you.
just type 'make'? does this compile according to the make file?
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

That's the rumor.

It'll show you the steps it takes, however. Good for learning.
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

okay well why wont toolchain.sh complie? that reason may that be? also is there a sample in the old one i can test?

edit: nm i got it working, i just righ click and set as excutable. =p
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

ooPo wrote:If you have already built the toolchain, you can go to /usr/local/ps2dev/ps2sdk/sample/hello and type 'make'. This will build a sample 'hello world' program for you.
this folder doesnt exist. is there anything else i was supose to install?
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

When you run toolchain.sh properly, it installs ps2sdk into /usr/local/ps2dev/ps2sdk. If that directory doesn't exist, something probably went wrong with the install.

Did you notice any error messages?
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

ooPo wrote:When you run toolchain.sh properly, it installs ps2sdk into /usr/local/ps2dev/ps2sdk. If that directory doesn't exist, something probably went wrong with the install.

Did you notice any error messages?
yeah it said in the end, ERROR INSTALLING BINUT or something like that.

i'm running on Knoppix. could that be a reason why its messed, up?
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

I don't run knoppix, so I have no idea.

Being a bit more specific with the error message may help, however.

One thing I do not understand is why you thought everything installed ok when it gave you an error.

Are you sure you're cut out for this?
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

yeah i'm sure i am cut out for this. i thought it installed okay, but i just checked again.
i've been programming for some time, in opengl. i am a windows user, and had a crash course on linux about a year ago. so linux is new to me(similar to dos tho). I am reading LDP docs to find out how linux runs inside out. i am getting the just of it, and able to compile code just fine. only having problems installing the toolchain. I would usually try to get it working on windows but i cant even get gcc to work on cygwin.

anyway this is the error i get with the old tool-chain.

Code: Select all

as: unrecognized option `-G'
make[2]: *** [libgcc/./_muldi3.o] Error 1
make[2]: Leaving directory `/ramdisk/home/knoppix/ps2toolchain-old/gcc-3.2.2/gcc'
make[1]: *** [libgcc.a] Error 2
make[1]: Leaving directory `/ramdisk/home/knoppix/ps2toolchain-old/gcc-3.2.2/gcc'
make: *** [all-gcc] Error 2
/bin/sh ./mkinstalldirs /usr/local/ps2dev/ee /usr/local/ps2dev/ee
mkdir /usr/local/ps2dev
mkdir /usr/local/ps2dev/ee
mkdir /usr/local/ps2dev
mkdir /usr/local/ps2dev/ee
make: *** [installdirs] Error 1
cp: cannot stat `/usr/local/ps2dev/ps2lib/ee/startup/crt0.o': No such file or directory

compiling code for the new one again now so see what the error is.
btw knoppixx is a linux live on CD, meaning everytime i restart the computer, all files get erease and runs off ram. but i have mounted a partition to store all save code into.

edit: when compiling new autobuild it starts of by saying this before installing

Code: Select all

CVS                  binutils-2.9.1-IOP.patch  newlib-1.10.0.patch
README.TXT           gcc-2.8.1-IOP.patch       toolchain-oldiop.sh
binutils-2.14.patch  gcc-3.2.2.patch           toolchain.sh
knoppix@ttyp0[ps2toolchain]$ ./toolchain.sh
cat: /home/knoppix/.cvspass: No such file or directory
THE SECRET PASSWORD IS: anonymous
Logging in to :pserver:[email protected]:2401/home/ps2cvs
CVS password:
cvs login: warning: failed to open /home/knoppix/.cvspass for reading: No such file or directory
./toolchain.sh: line 35: gmake: command not found
my guess checks to see if i have it downloaded yet or not, and if not it download the files. not sure tho. and it ends with this.

Code: Select all

make[3]: *** [tc-mips.o] Error 1
make[3]: Leaving directory `/ramdisk/var/tmp/ps2dev/binutils-2.14/build-ee/gas'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/ramdisk/var/tmp/ps2dev/binutils-2.14/build-ee/gas'
make[1]: *** [all-recursive-am] Error 2
make[1]: Leaving directory `/ramdisk/var/tmp/ps2dev/binutils-2.14/build-ee/gas'
make: *** [all-gas] Error 2
ERROR BUILDING BINUTILS (binutils-2.14 ee)

btw oopo: what version of linux are you using? Fedora? is there any other steps i am supose to take before running toolchain.sh?
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Problem Fix

Post by Thanhda »

okay, i manage to install it. the reason it was giving me errors was because user/local/ is read only. i tried whiching to root by typing su, but still wont allow me to install. so i just modifed the toolchain.sh file path to /home/knoppix/local/ and it works fine so far.
cheriff
Regular
Posts: 258
Joined: Wed Jun 23, 2004 5:35 pm
Location: Sydney.au

Post by cheriff »

with Knoppix, there is an icon in the "start menu" which opens a terminal as superuser. The reason you can't use su is because there is no root password set. If you can set the root password yourself, su will work as normal.

Also, Because knoppix is a live CD, directories /usr and such are run right off the CD, i think any additions to this you make are kept in a ramdir. So with the default setup you may have to re-install the toolchain every reboot.

Since you have a disk partition setup for your homedir, it may be advisable to edit the toochain.sh to install to /mnt/mypartition/ps2, or whereever the disk is mounted. Remember to change $PS2SDK to reflect this.

But my serious advice would to be to do all this under cygwin in windows, or even install a linux partition...
- cheriff
Damn, I need a decent signature!
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

In the toolchain script, $PS2SDK should automatically use $PS2DEV/ps2sdk, so you'd only need to change $PS2DEV.
rinco
Posts: 255
Joined: Fri Jan 21, 2005 2:12 pm
Location: Canberra, Australia

Post by rinco »

cheriff wrote:with Knoppix, there is an icon in the "start menu" which opens a terminal as superuser. The reason you can't use su is because there is no root password set. If you can set the root password yourself, su will work as normal.
I thought you could use sudo to get a root shell.... sudo bash
But my serious advice would to be to do all this under cygwin in windows, or even install a linux partition...
I was thinking exactly the same thing.
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

well, i'm just want to see if i can get the enviroment all set up. i plan to reformat my computer, and create a partition for both my windows and linux OS. i'm downloading the Fedora ISO as we speak. if someone would like to recommend another Linux OS let me know.
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

okay, still no compile, i finally got the toolchain to compile Fedora 3.

when i go to the samples/hello/ i type make, and it gives me this error

Code: Select all

ee-gcc -D_EE -O2 -G0 -Wall  -I/ee/include -I/common/include -I.  -c hello.c -o hello.o
make: ee-gcc: Command not found
make: *** [hello.o] Error 127
originally it said no such file. but i modifed the make file to go to the dir. and now i get this.

i'm guessing ee-gcc is not installed. but shouldnt toolchain.sh install it?

but when i place the code into the ee/bin folder it compiles, but gives me this answer

Code: Select all

[root@localhost bin]# ./ee-gcc -D_EE -O2 -G0 -Wall  -I/ee/include -I/common/include -I.  -c hello.c -o hello.o
hello.c:14:22: tamtypes.h: No such file or directory
hello.c:15:20: sifcmd.h: No such file or directory
hello.c:16:20: kernel.h: No such file or directory
hello.c:17:20: sifrpc.h: No such file or directory
hello.c:18:17: sio.h: No such file or directory
hello.c: In function `main':
hello.c:22: warning: implicit declaration of function `SifInitRpc'
hello.c:27: warning: implicit declaration of function `printf'
hello.c:28: warning: implicit declaration of function `nprintf'
hello.c:30: warning: implicit declaration of function `sio_init'
hello.c:31: warning: implicit declaration of function `sio_printf'

There are 10 types of people in the world: Those who understand binary, and those who don't...
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

You dont seem to have the PS2* specific env variables defined.

read the top of toolchain.sh
Kung VU
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

blackdroid wrote:You dont seem to have the PS2* specific env variables defined.

read the top of toolchain.sh

Code: Select all

#!/bin/sh
# toolchain.sh - Dan Peori <[email protected]>
# Copy all you want. Please give me some credit.

 ########################
 ## MAIN CONFIGURATION ##
 ########################

  ## Main ps2dev settings.
  export PS2DEV="/usr/local/ps2dev"
  export PS2SDK="$PS2DEV/ps2sdk"
  export CVSROOT="&#58;pserver&#58;[email protected]&#58;2401/home/ps2cvs"
  export PAT
what am i looking for?
There are 10 types of people in the world: Those who understand binary, and those who don't...
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

From the included README.TXT:
==================
HOW DO I USE IT?
==================

Basically, you run the toolchain script:

## Make the script executable.
chmod a+x ./toolchain.sh

## Run the script.
./toolchain.sh

First, this script will attempt to make sure you have all the programs
you need to build the toolchain. Then it will download the source from
various places on the internet. Finally, it will compile and build the
source. This may take a long time.

Once finished, you need to add the following to your login settings:

## PS2DEV SETTINGS
export PS2DEV="/usr/local/ps2dev"
export PS2SDK="$PS2DEV/ps2sdk"
export CVSROOT=":pserver:[email protected]:/home/ps2cvs"
export PATH="$PATH:$PS2DEV/bin:$PS2DEV/ee/bin:$PS2DEV/iop/bin:$PS2DEV/dvp/bin:$PS2SDK/bin"

Then you're done!
You can view the latest version in cvs yourself at:

http://cvs.ps2dev.org/ps2toolchain/READ ... cvs-markup
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

ooPo wrote:From the included README.TXT:
You can view the latest version in cvs yourself at:

http://cvs.ps2dev.org/ps2toolchain/READ ... cvs-markup
thanks man, got it to compile. works good now. but one small question, how do i place this in my login. i can get this to work when i switch to root and type the command lines in. but how do i get it to stay that way without having to do it everytime i boot up. besides creating a bat file.
There are 10 types of people in the world: Those who understand binary, and those who don't...
carlosn
Posts: 38
Joined: Thu Mar 10, 2005 2:14 am
Location: Orlando, Florida, US
Contact:

Post by carlosn »

Type all the export lines at the end of your ".bash_profile" file. This file contains your login settings. The file is located in your home directory.
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

carlosn wrote:Type all the export lines at the end of your ".bash_profile" file. This file contains your login settings. The file is located in your home directory.
there isnt such a file in the home dir. only see folder.
There are 10 types of people in the world: Those who understand binary, and those who don't...
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

You banter about the good of linux, yet you cant use the system, please read up on basic unix/bash shell usage. This is afterall not a unix support forum.
Kung VU
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

blackdroid wrote:You banter about the good of linux, yet you cant use the system, please read up on basic unix/bash shell usage. This is afterall not a unix support forum.
it is good, i just dont know how to set this up. plus the setup of getting it on linux is SOOOOO much easier then windows. i have already manage to program a small demo for the ps2 and get it to compile. and i have yet to get it even to compile or install the toolchain on windows through cygwin. i've spend a good month trying to get it working on windows. and less then a day to set it up on linux. hmm whats better.

btw yes i figure it out. i have read the ldp.
There are 10 types of people in the world: Those who understand binary, and those who don't...
Post Reply