Tutorial: Setting up CodeBlocks for ps2dev
Posted: Sat Nov 18, 2006 4:23 pm
Goal
This guide breaks down into two parts:
Setting up a ps2dev environment, for those who want to try this without ps2dev experience
Setting up CodeBlocks to compile ps2dev projects, works for Cygwin, MinGW, or precompiled toolchain users
What you need for CodeBlocks
CodeBlocks, www.codeblocks.org/nightly
Get the latest nightly build
These dlls are listed in each nightly build release thread: mingwm10.7z wxmsw26u_gcc_cb_wx2.6.3p2.7z
What you need for ps2dev environment
MinGW/MSYS, www.mingw.org
Download MinGW-5.0.2.exe, it's an installer like Cygwin's
I have MSYS-1.0.11-2004.04.30-1.exe, which was the latest MSYS installer snapshot.
This has all the commandline tools, make, sh, tar, gawk, sed, generally used in buildscripts/makefiles.
ps2dev-project template, http://homebrew.thewaffleiron.net/ragna ... project.7z
This is a simple CodeBlocks project file for setting up ps2 projects, you should copy it into the same dir as a project's main Makefile
A Subversion client to download ps2sdk/usb_mass
I used RapidSVN, http://rapidsvn.tigris.org/
Setting up a ps2dev environment
MinGW Setup:
Run MinGW-5.0.2.exe, it will go online to check the latest version of MinGW
Click Next, select a mirror near you in the list, select download and install Click Next
Click either Current or Candidate, Click Next
You want the MinGW base tools, and G++ checked, Click Next, and it will start downloading
Install to C:\MinGW
MSYS setup:
Install MSYS to C:\msys not C:\msys\1.0
Continue with the post-install, so put y and hit Enter.
Hit y and Enter when it asks if you have MinGW installed.
c:/mingw for your MinGW installation, Hit Enter to continue
All done.
The colors for the terminal are set in msys.bat.
You can change LightYellow/Navy to Black/LightGrey so it resembled a more normal terminal window.
You can also add -norxvt to the MSYS shortcut on the desktop to start off with just a simple shell.
Toolchain setup:
Compile or Install a precompiled toolchain to /c/ps2dev or /opt/ps2dev
Open up C:\msys\etc\profile and paste the following at the bottom:
export PS2DEV="/c/ps2dev"
export PS2SDK="$PS2DEV/ps2sdk"
export PATH="$PATH:$PS2DEV/bin:$PS2DEV/ee/bin:$PS2DEV/iop/bin:$PS2DEV/dvp/bin:$PS2SDK/bin"
This sets MSYS's environment up with all the ps2dev dependent variables for compiling with ps2sdk.
Setting up CodeBlocks
CodeBlocks setup:
Extract the latest nightly build, mingwm10.7z, and wxmsw26u_gcc_cb_wx2.6.3p2.7z into C:\Program Files\CodeBlocks
Right click codeblocks.exe and click Send To->Desktop (create shortcut), if you want, you can rename the shortcut CodeBlocks.
Start CodeBlocks, if you get the following error
"Can not enumerate files in directory: 'C:\Documents and Settings\<username>\Application Data\codeblocks/share/codeblocks/plugins' (error 3: the system can not find the file specified.)"
You just need to create that plugins folder.
You can go to Settings->Environment, and enable file associations, if you want.
If you wish to retain your file associations for source files. Click Manage... and just have .cbp and .workspace checked before doing anything
Compiler Setup:
Inside CodeBlocks
Go to Settings-> Environment
Scroll down to Environment variables and click on the icon
Add the following:
Key: PS2DEV
Value: C:/ps2dev (for Cygwin users, change that to your ps2dev dir) it needs forward /'s
Key: PS2SDK
Value: $(PS2DEV)/ps2sdk
Click the Add now (or Set now) button, Click OK
Go to Settings-> Compiler and debugger settings
Select GNU GCC Compiler in the dropdown box at the top, and click the Copy button.
Put PS2 GCC Compiler in the Input box and click OK.
Select the PS2 GCC Compiler in the dropdown list
For MinGW users, CodeBlocks has all the MinGW directories configured by default
For Cygwin users, http://wiki.codeblocks.org/index.php?ti ... n_Compiler
The programs should be setup like this (both MinGW and Cygwin):
Toolchain executables
C Compiler: gcc.exe (or mingw-gcc.exe)
C++ Compiler: g++.exe (or mingw-g++.exe)
Linker for dynamic libs: g++.exe (or mingw-g++.exe)
Linker for static libs: ar.exe
Debugger: gdb.exe
Resource compiler: windres.exe
Make program: make.exe
Additional Paths tab
C:\msys\bin
C:\ps2dev\ee\bin
C:\ps2dev\iop\bin
C:\ps2dev\dvp\bin
C:\ps2dev\ps2sdk\bin
C:\ps2dev\bin
Cygwin users can change those to their relevant paths, they don't need C:\msys\bin
Example project setup:
Get the usb_mass source from ps2dev's subversion repository, this was my test project as it had separate iop and ee projects.
Copy the ps2dev.cbp into the ee folder. For any ps2 project, you want the .cbp file in the same directory as the main makefile for the project, as it keeps the same relative paths in CodeBlocks when you do that.
You can rename it to mass_example.cbp, then doubleclick it
Configuring project for compiling:
Right-click the project, ps2dev, in Codeblocks, click Properties, replace the ps2dev title with whatever you want, I chose mass_example.
Right-clik the project, click Add files recursively... and select the ee dir (should already be selected since that's whare the .cbp is). Make sure all the source files are checked, plus the Makefile
You should now see:
Building:
Right-click the Project name and click Build, you should get some warning messages, but it should complete without errors. Cygwin users/Cygwin-based toolchain users, if there are no line numbers or filenames with the warning messages, please read below.
You can also put a fresh copy of ps2dev.cbp into the iop folder, add the files recursively from the iop folder, click Build, it will compile, too.
Cygwin-hosted toolchain users
For those with Cygwin or those with a toolchain from a cygwin-hosted ps2dev environment installer (needs cygwin1.dll), CodeBlocks' regex's didn't capture GCC's output correctly for me
If, when compiling mass_example, the warnings in the Build messages box do not have line numbers or file names listed, then do the following:
Open CodeBlocks, go to Settings-> Compiler and debugger settings
Select the PS2 GCC Compiler from the dropdown list
Click the Other tab, click Advanced options..., you will get a warning about the ramifications of changing things and asks if you wish to continue, make sure you have the PS2 GCC Compiler selected, and click Yes
Click the Output Parsing tab
For the following, you need to replace the regex's with ones that can parse the cygwin-hosted gcc output. The messages under Testing: are example warnings/errors. Paste them into the Test string box, you should get a dialog with everything parsed correctly.
Now CodeBlocks should catch warnings and errors correctly, allowing you to jump straight to where said warning/error occurred from the Build messages box.
Updating PS2SDK:
Get the latest ps2sdk's source from ps2dev's svn repository.
Comments
Ok, I've spent a few days creating this guide, I'm pretty sure I've caught anything that might mess CodeBlocks up with setting it up with a ps2dev environment on any platform. As for Linux users, there is an Ubuntu edgy nightly build, but I'm not familiar with it, but you can probably figure out how to set it up from this guide.
This guide breaks down into two parts:
Setting up a ps2dev environment, for those who want to try this without ps2dev experience
Setting up CodeBlocks to compile ps2dev projects, works for Cygwin, MinGW, or precompiled toolchain users
What you need for CodeBlocks
CodeBlocks, www.codeblocks.org/nightly
Get the latest nightly build
These dlls are listed in each nightly build release thread: mingwm10.7z wxmsw26u_gcc_cb_wx2.6.3p2.7z
What you need for ps2dev environment
MinGW/MSYS, www.mingw.org
Download MinGW-5.0.2.exe, it's an installer like Cygwin's
I have MSYS-1.0.11-2004.04.30-1.exe, which was the latest MSYS installer snapshot.
This has all the commandline tools, make, sh, tar, gawk, sed, generally used in buildscripts/makefiles.
ps2dev-project template, http://homebrew.thewaffleiron.net/ragna ... project.7z
This is a simple CodeBlocks project file for setting up ps2 projects, you should copy it into the same dir as a project's main Makefile
A Subversion client to download ps2sdk/usb_mass
I used RapidSVN, http://rapidsvn.tigris.org/
Setting up a ps2dev environment
MinGW Setup:
Run MinGW-5.0.2.exe, it will go online to check the latest version of MinGW
Click Next, select a mirror near you in the list, select download and install Click Next
Click either Current or Candidate, Click Next
You want the MinGW base tools, and G++ checked, Click Next, and it will start downloading
Install to C:\MinGW
MSYS setup:
Install MSYS to C:\msys not C:\msys\1.0
Continue with the post-install, so put y and hit Enter.
Hit y and Enter when it asks if you have MinGW installed.
c:/mingw for your MinGW installation, Hit Enter to continue
All done.
The colors for the terminal are set in msys.bat.
You can change LightYellow/Navy to Black/LightGrey so it resembled a more normal terminal window.
You can also add -norxvt to the MSYS shortcut on the desktop to start off with just a simple shell.
Toolchain setup:
Compile or Install a precompiled toolchain to /c/ps2dev or /opt/ps2dev
Open up C:\msys\etc\profile and paste the following at the bottom:
export PS2DEV="/c/ps2dev"
export PS2SDK="$PS2DEV/ps2sdk"
export PATH="$PATH:$PS2DEV/bin:$PS2DEV/ee/bin:$PS2DEV/iop/bin:$PS2DEV/dvp/bin:$PS2SDK/bin"
This sets MSYS's environment up with all the ps2dev dependent variables for compiling with ps2sdk.
Setting up CodeBlocks
CodeBlocks setup:
Extract the latest nightly build, mingwm10.7z, and wxmsw26u_gcc_cb_wx2.6.3p2.7z into C:\Program Files\CodeBlocks
Right click codeblocks.exe and click Send To->Desktop (create shortcut), if you want, you can rename the shortcut CodeBlocks.
Start CodeBlocks, if you get the following error
"Can not enumerate files in directory: 'C:\Documents and Settings\<username>\Application Data\codeblocks/share/codeblocks/plugins' (error 3: the system can not find the file specified.)"
You just need to create that plugins folder.
You can go to Settings->Environment, and enable file associations, if you want.
If you wish to retain your file associations for source files. Click Manage... and just have .cbp and .workspace checked before doing anything
Compiler Setup:
Inside CodeBlocks
Go to Settings-> Environment
Scroll down to Environment variables and click on the icon
Add the following:
Key: PS2DEV
Value: C:/ps2dev (for Cygwin users, change that to your ps2dev dir) it needs forward /'s
Key: PS2SDK
Value: $(PS2DEV)/ps2sdk
Click the Add now (or Set now) button, Click OK
Go to Settings-> Compiler and debugger settings
Select GNU GCC Compiler in the dropdown box at the top, and click the Copy button.
Put PS2 GCC Compiler in the Input box and click OK.
Select the PS2 GCC Compiler in the dropdown list
For MinGW users, CodeBlocks has all the MinGW directories configured by default
For Cygwin users, http://wiki.codeblocks.org/index.php?ti ... n_Compiler
The programs should be setup like this (both MinGW and Cygwin):
Toolchain executables
C Compiler: gcc.exe (or mingw-gcc.exe)
C++ Compiler: g++.exe (or mingw-g++.exe)
Linker for dynamic libs: g++.exe (or mingw-g++.exe)
Linker for static libs: ar.exe
Debugger: gdb.exe
Resource compiler: windres.exe
Make program: make.exe
Additional Paths tab
C:\msys\bin
C:\ps2dev\ee\bin
C:\ps2dev\iop\bin
C:\ps2dev\dvp\bin
C:\ps2dev\ps2sdk\bin
C:\ps2dev\bin
Cygwin users can change those to their relevant paths, they don't need C:\msys\bin
Example project setup:
Get the usb_mass source from ps2dev's subversion repository, this was my test project as it had separate iop and ee projects.
Copy the ps2dev.cbp into the ee folder. For any ps2 project, you want the .cbp file in the same directory as the main makefile for the project, as it keeps the same relative paths in CodeBlocks when you do that.
You can rename it to mass_example.cbp, then doubleclick it
Configuring project for compiling:
Right-click the project, ps2dev, in Codeblocks, click Properties, replace the ps2dev title with whatever you want, I chose mass_example.
Right-clik the project, click Add files recursively... and select the ee dir (should already be selected since that's whare the .cbp is). Make sure all the source files are checked, plus the Makefile
You should now see:
Code: Select all
-#usb_mass
- Sources
mass_example.c
mass_rpc.c
+ Headers
+ Others
Right-click the Project name and click Build, you should get some warning messages, but it should complete without errors. Cygwin users/Cygwin-based toolchain users, if there are no line numbers or filenames with the warning messages, please read below.
You can also put a fresh copy of ps2dev.cbp into the iop folder, add the files recursively from the iop folder, click Build, it will compile, too.
Cygwin-hosted toolchain users
For those with Cygwin or those with a toolchain from a cygwin-hosted ps2dev environment installer (needs cygwin1.dll), CodeBlocks' regex's didn't capture GCC's output correctly for me
If, when compiling mass_example, the warnings in the Build messages box do not have line numbers or file names listed, then do the following:
Open CodeBlocks, go to Settings-> Compiler and debugger settings
Select the PS2 GCC Compiler from the dropdown list
Click the Other tab, click Advanced options..., you will get a warning about the ramifications of changing things and asks if you wish to continue, make sure you have the PS2 GCC Compiler selected, and click Yes
Click the Output Parsing tab
For the following, you need to replace the regex's with ones that can parse the cygwin-hosted gcc output. The messages under Testing: are example warnings/errors. Paste them into the Test string box, you should get a dialog with everything parsed correctly.
Code: Select all
Click Compiler warning
Replace
([ \tA-Za-z0-9_:+/\.-]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)
with
([ \tA-Za-z0-9_:+/\.-]+)\(([0-9]+)\)[ \t]:[ \t]([Ww]arning:[ \t].*)
Testing
main.c:38: warning: implicit declaration of function `InitPS2'
main.c(38) : warning: implicit declaration of function `InitPS2'
Click Compiler error
Replace
([ \tA-Za-z0-9_:+/\.-]+):([0-9]+):[ \t](.*)
with
([ \tA-Za-z0-9_:+/\.-]+)\(([0-9]+)\)[ \t]:[ \t](.*)
Testing:
init.c:80: parse error before '*' token
init.c(80) : parse error before '*' token
Click Linker error (lib not found)
Replace
.*(ld.exe):[ \t](cannot find.*)
with
.*(ld):[ \t](cannot find.*)
Testing:
C:\ps2dev\ee\bin\..\lib\gcc-lib\ee\3.2.2\..\..\..\..\ee\bin\ld.exe: cannot find -ldmkit
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/bin/ld: cannot find -ldmkit
Updating PS2SDK:
Get the latest ps2sdk's source from ps2dev's svn repository.
Comments
Ok, I've spent a few days creating this guide, I'm pretty sure I've caught anything that might mess CodeBlocks up with setting it up with a ps2dev environment on any platform. As for Linux users, there is an Ubuntu edgy nightly build, but I'm not familiar with it, but you can probably figure out how to set it up from this guide.