PS2 [TUTORIAL] Setup the Code::Blocks IDE for PS2 Development (With PCSX2) On Windows and Linux

RinasSam

Member
I want to share a tutorial with you all about how to use the Code::Blocks (which will be referred to as CB in this thread) IDE for PS2 development.
This tutorial should work for both Linux and Windows.

Before Starting, What is Code::Blocks?
-Code::Blocks (CB) is a free C and C++ integrated development environment (IDE) that is designed to be highly extensible and configurable. It includes a wide range of features including:
  • Multiple Compiler Support (more compilers can be supported manually).
  • Syntax Highlighting.
  • Code Completion (very useful feature).
  • Documentation Generator.
  • External Customizable Tools.
  • Games to keep you occupied while waiting for your code to compile (No joke it even has Tetris).
  • and Much More. Read more about CB's features here: http://www.codeblocks.org/features
Do note that CB is NOT:
  • A compiler.
  • A linker.
With that covered we can start.

Step 1: Getting CB:
You can get CB from their downloads page: http://www.codeblocks.org/downloads
Make sure to install the one for your OS if you are going to download from the binary builds.
For Windows users it is best to install the mingw-setup installer.

Step 2: Getting The PS2DEV Tools:
-If you are on Linux:
  1. Get Git. Use your distro's package manager to install it. Two of the most popular package managers on Linux are apt and pacman.
  2. Get the PS2DEV tools here: https://github.com/ps2dev/ps2dev
  3. Make sure to read README.MD for the installation instructions.
-If you are on Windows:
  1. Get the precompiled PS2DEV tools with MSYS here: https://github.com/ps2dev/ps2toolchain/releases
  2. Extract it to a good location. (C:\) works well.


Note 1: The precompiled toolchain may be old.
Note 2: The C++ compiler (g++) is NOT included in the precompiled toolchain. You can however, easily get it by searching for it on the internet.


[OPTIONAL] Step 3: Getting PCSX2:
PCSX2 is a Playstation 2 emulator for the PC. It is possible to use PCSX2 for PS2 development.
In this tutorial we will be using PCSX2 1.4.0.
If you are on Linux, get it from here: https://pcsx2.net/download/releases/linux/category/3-linux.html
If you are on Windows, get it from here: https://pcsx2.net/download/releases/archive-download/category/43-pcsx2-v1-4-0.html


Note 1: It is best to download the portable executables.

Note 2:I was NOT able to use the newer versions of PCSX2 for PS2 development with CB. Only version 1.4.0 worked well.

Step 4: Setting Up CB:

  1. Run CB on your machine.
  2. Click on Settings > Compiler...
  3. You should see the Global Compiler Settings screen:


    upload_2021-1-21_18-9-54.png
    upload_2021-1-21_18-19-58.png
    upload_2021-1-21_18-25-53.png
    upload_2021-1-21_18-34-50.png
    upload_2021-1-21_18-41-17.png
    upload_2021-1-21_18-42-11.png
    upload_2021-1-21_18-43-46.png
    upload_2021-1-21_18-52-16.png
    upload_2021-1-21_18-9-54.png
    upload_2021-1-21_18-19-58.png
    upload_2021-1-21_18-25-53.png
    upload_2021-1-21_18-34-50.png
    upload_2021-1-21_18-41-17.png
    upload_2021-1-21_18-42-11.png
    upload_2021-1-21_18-43-46.png
    upload_2021-1-21_18-43-46.png
    upload_2021-1-21_18-52-16.png

    upload_2021-1-21_18-9-54.png


  4. Check if the GNU GCC Compiler is correctly set.
  5. Click on the Copy button.
  6. In the dialog asking to enter the new compiler name, enter a name for the compiler. I chose PS2-GCC.
  7. Go to Toolchain Executables.
  8. If you are on Windows, change the compiler's installation directory to the one in your MSYS directory (should be C:\path\to\msys\MinGW)
  9. In Program Files:


    upload_2021-1-21_18-19-58.png




    make sure that the program setup looks like the image above.

    Note 1: The C compiler may be gcc or mingw32-gcc
    Note 2: The C++ compiler may be g++ or mingw32-g++
    Note 3: The Linker for dynamic libs should be the same as the C++ compiler.
    Note 4: The Make program may be make or ming32-make
  10. Head over to Additional Paths.
  11. Add the bin folders of MSYS, PS2DEV, PS2SDK, EE, IOP, and DVP here.
    If you are on Windows it will look something like this:

    upload_2021-1-21_18-25-53.png




    Note: add the PCSX2 folder (the one with the PCSX2 executable) of PCSX2 if you plan on using it for PS2 development.
  12. The compiler should be set up now. Click OK and go to Settings > Environment > Environment Variables:


    upload_2021-1-21_18-34-50.png



  13. Add the following Env. variables:
    -PS2DEV = path/to/ps2dev folder
    -PS2SDK = $(PS2DEV)/ps2sdk
    -PS2SDKSRC = $(PS2DEV)/ps2sdksrc
    -PS2LIB = $(PS2DEV)/ps2lib
    -PS2ETH = $(PS2DEV)/ps2eth
    -GSKIT = $(PS2DEV)/gsKit
  14. Click on Set Now.
    Now everything should be set up. Only 3 things are left to be done:
    a- Setting up Code Completion to work with PS2 development.
    b- Setting up useful tools for PS2 development.
    c- Setting up an example project.
  15. We will start by setting up the tools. Head to Tools > Configure tools...:


    upload_2021-1-21_18-41-17.png




  16. Add ps2client and set it up to look similar to this:


    upload_2021-1-21_18-42-11.png



  17. Reset tool is the same as ps2client but instead of the parameters being execee host:output, it is just reset.
  18. If you are on Windows you may also want to add the MSYS shell. Configure it to similar to this:


    upload_2021-1-21_18-43-46.png



  19. You can also set up PCSX2. Remember to set the parameters to:
    --console --nogui --elf="${PROJECT_DIR}${TARGET_OUTPUT_FILE}"


  20. Now we can set up Code Completion and a template project in a few simple steps.
    Use the preconfigured CB project file I have included in this thread (PS2.zip. It includes the PS2.cbp preconfigured project file).
  21. Open the preconfigured .cbp file with CB.
  22. Click on File > Save Project As Template.
  23. Give it a name and save it.

Extra Information: How to Setup Code Completion?

After creating a new project, head to
Project > Properties > C/C++ Parser Options and make sure that Additional Search Paths look similar to this:


upload_2021-1-21_18-52-16.png



Notes About the Preconfigured PS2.cbp File:
1-It will launch PCSX2 to run your program if you are in Debug mode.
2-It will run ps2client if you are on release mode.

If you do NOT want that just head to Project > Build Options:

  1. Go to debug and remove everything.
  2. Go to release and remove everything.
  3. If asked to save changes say yes.
3-Its output file is PS2.ELF. To change it go to Project > Properties > Build Targets and change the output filename.

Step 5 [FINALE]: Testing Your Setup:
To test your setup use an example ps2dev project (the usb_mass source is one of the best ones to use) and add its files to the project. Then build the project and hope that your setup is working.


Conclusion:
So this marks the end of this tutorial on setting up CB for PS2 development. I hope you found this useful.
If you have any question, problems, or remarks feel free to leave them here.
 

Attachments

Last edited by a moderator:
There is for some reason an inability to edit the thread so at the time of writing this I am trying to fix this.
 
FIXED:

I want to share a tutorial with you all about how to use the Code::Blocks (which will be referred to as CB in this thread) IDE for PS2 development.
This tutorial should work for both Linux and Windows.

Before Starting, What is Code::Blocks?
-Code::Blocks (CB) is a free C and C++ integrated development environment (IDE) that is designed to be highly extensible and configurable. It includes a wide range of features including:
  • Multiple Compiler Support (more compilers can be supported manually).
  • Syntax Highlighting.
  • Code Completion (very useful feature).
  • Documentation Generator.
  • External Customizable Tools.
  • Games to keep you occupied while waiting for your code to compile (No joke it even has Tetris).
  • and Much More. Read more about CB's features here: http://www.codeblocks.org/features
Do note that CB is NOT:
  • A compiler.
  • A linker.
With that covered we can start.

Step 1: Getting CB:
You can get CB from their downloads page: http://www.codeblocks.org/downloads
Make sure to install the one for your OS if you are going to download from the binary builds.
For Windows users it is best to install the mingw-setup installer.

Step 2: Getting The PS2DEV Tools:
-If you are on Linux:
  1. Get Git. Use your distro's package manager to install it. Two of the most popular package managers on Linux are apt and pacman.
  2. Get the PS2DEV tools here: https://github.com/ps2dev/ps2dev
  3. Make sure to read README.MD for the installation instructions.
-If you are on Windows:
  1. Get the precompiled PS2DEV tools with MSYS here: https://github.com/ps2dev/ps2toolchain/releases
  2. Extract it to a good location. (C:\) works well.


Note 1: The precompiled toolchain may be old.
Note 2: The C++ compiler (g++) is NOT included in the precompiled toolchain. You can however, easily get it by searching for it on the internet.


[OPTIONAL] Step 3: Getting PCSX2:
PCSX2 is a Playstation 2 emulator for the PC. It is possible to use PCSX2 for PS2 development.
In this tutorial we will be using PCSX2 1.4.0.
If you are on Linux, get it from here: https://pcsx2.net/download/releases/linux/category/3-linux.html
If you are on Windows, get it from here: https://pcsx2.net/download/releases/archive-download/category/43-pcsx2-v1-4-0.html

Note 1: It is best to download the portable executables.

Note 2:I was NOT able to use the newer versions of PCSX2 for PS2 development with CB. Only version 1.4.0 worked well.

Step 4: Setting Up CB:
  1. Run CB on your machine.
  2. Click on Settings > Compiler...
  3. You should see the Global Compiler Settings screen:



  4. Check if the GNU GCC Compiler is correctly set.
  5. Click on the Copy button.
  6. In the dialog asking to enter the new compiler name, enter a name for the compiler. I chose PS2-GCC.
  7. Go to Toolchain Executables.
  8. If you are on Windows, change the compiler's installation directory to the one in your MSYS directory (should be C:\path\to\msys\MinGW)
  9. In Program Files:






    make sure that the program setup looks like the image above.

    Note 1: The C compiler may be gcc or mingw32-gcc
    Note 2: The C++ compiler may be g++ or mingw32-g++
    Note 3: The Linker for dynamic libs should be the same as the C++ compiler.
    Note 4: The Make program may be make or ming32-make
  10. Head over to Additional Paths.
  11. Add the bin folders of MSYS, PS2DEV, PS2SDK, EE, IOP, and DVP here.
    If you are on Windows it will look something like this:





    Note: add the PCSX2 folder (the one with the PCSX2 executable) of PCSX2 if you plan on using it for PS2 development.
  12. The compiler should be set up now. Click OK and go to Settings > Environment > Environment Variables:




  13. Add the following Env. variables:
    -PS2DEV = path/to/ps2dev folder
    -PS2SDK = $(PS2DEV)/ps2sdk
    -PS2SDKSRC = $(PS2DEV)/ps2sdksrc
    -PS2LIB = $(PS2DEV)/ps2lib
    -PS2ETH = $(PS2DEV)/ps2eth
    -GSKIT = $(PS2DEV)/gsKit
  14. Click on Set Now.
    Now everything should be set up. Only 3 things are left to be done:
    a- Setting up Code Completion to work with PS2 development.
    b- Setting up useful tools for PS2 development.
    c- Setting up an example project.
  15. We will start by setting up the tools. Head to Tools > Configure tools...:





  16. Add ps2client and set it up to look similar to this:





  17. Reset tool is the same as ps2client but instead of the parameters being execee host:output, it is just reset.
  18. If you are on Windows you may also want to add the MSYS shell. Configure it to similar to this:





  19. You can also set up PCSX2. Remember to set the parameters to:
    --console --nogui --elf="${PROJECT_DIR}${TARGET_OUTPUT_FILE}"


  20. Now we can set up Code Completion and a template project in a few simple steps.
    Use the preconfigured CB project file I have included in this thread (PS2.zip. It includes the PS2.cbp preconfigured project file).
  21. Open the preconfigured .cbp file with CB.
  22. Click on File > Save Project As Template.
  23. Give it a name and save it.

Extra Information: How to Setup Code Completion?

After creating a new project, head to Project > Properties > C/C++ Parser Options and make sure that Additional Search Paths look similar to this:





Notes About the Preconfigured PS2.cbp File:
1-It will launch PCSX2 to run your program if you are in Debug mode.
2-It will run ps2client if you are on release mode.

If you do NOT want that just head to Project > Build Options:
  1. Go to debug and remove everything.
  2. Go to release and remove everything.
  3. If asked to save changes say yes.
3-Its output file is PS2.ELF. To change it go to Project > Properties > Build Targets and change the output filename.

Step 5 [FINALE]: Testing Your Setup:
To test your setup use an example ps2dev project (the usb_mass source is one of the best ones to use) and add its files to the project. Then build the project and hope that your setup is working.


Conclusion:
So this marks the end of this tutorial on setting up CB for PS2 development. I hope you found this useful.
If you have any question, problems, or remarks feel free to leave them here.
 
There is for some reason an inability to edit the thread so at the time of writing this I am trying to fix this.
Is because you are a new forum user with few amount of posts so you have some restrictions, soon will be lifted
In the meantime do whatever you want in this thread, and advise us later to clean it up
After the restrictions of your user profile are lifted you are going to be able to edit all your posts, we can also delete the ones you dont need, etc..

Nice tutorial btw :encouragement:
 
Is because you are a new forum user with few amount of posts so you have some restrictions, soon will be lifted
In the meantime do whatever you want in this thread, and advise us later to clean it up
After the restrictions of your user profile are lifted you are going to be able to edit all your posts, we can also delete the ones you dont need, etc..

Nice tutorial btw :encouragement:

Ah that explains a lot. Thanks.
 
Interesting!

I want to update the WSL-Tutorial (multi-console, currently including the PS2SDK and PSL1ght, but I will add PSn00bSDK and the Vita-SDK soon) these days anyway, so I will include a link to this thread and maybe an adapted version of your tutorial.

@RinasSam You can edit your posts after a while and a certain amount of posts (I think 10.)! ;)
I can replace your first post with your other post, if you want to.
 
Interesting!

I want to update the WSL-Tutorial (multi-console, currently including the PS2SDK and PSL1ght, but I will add PSn00bSDK and the Vita-SDK soon) these days anyway, so I will include a link to this thread and maybe an adapted version of your tutorial.

@RinasSam You can edit your posts after a while and a certain amount of posts (I think 10.)! ;)
I can replace your first post with your other post, if you want to.

Yes please that would be fairly helpful.
 
Thanks i have installed it and work in windows.But one question how i can compile iop code?(irx).The examples appear compile only for the ee.
 

Similar threads

Back
Top