I found the instructions at Ngine and Hitmen to be an excellent start. But as I progressed I found that these just weren't enough help to be completely useful because I needed C++ as well as C.

At work, I did start using CygWin (later installed Linux at work) and although it is very good (for what it is), the best platform to use for development is Linux. I say this, because the tools you will be using were developed on Linux and were meant for a Unix(ish) environment. So, the instructions here will be aimed at Linux users.

First, get the following software:

Alternately, you can get GCC from GNU and Newlib from RedHat.


I got these patches originally from MRBrown, but they didn't apply cleanly; so I applied them by hand and created some newer patches for the above packages. I have compiled the libdream 320x240 demo using these patches and they seem to work, so here they are:


  1. Specify the environment variables:

    BASH$ target=sh-elf; prefix=/usr/local; i=$prefix/bin

  2. Compile binutils for SH4:

    First, you want to make a directory to put all of your source code into. It's probably better to log in as root and do in /usr/src. We'll call our directory xgcc.

    Make your /usr/src/xgcc directory and cd into it. Then type the following commands:

    At this point you will want to export the path to your new tools: export PATH=/usr/src/xgcc/bin, this will stop the gcc build failing halfway through.

  3. Compile GCC for SH4:

  4. Compile Newlib for SH4:

  5. At this point you will want to export the path to your new tools: export PATH=/usr/src/xgcc/bin, this will stop the gcc build failing halfway through.

    Compile GCC for SH4:


I have a simple script to handle this compile, you can get that here.

That's almost it! You still need a couple more files to be ready to compile:

Now, you need to assemble the startup file and install it in the correct place:

That's it! You should now have a complete (C/C++) installation of the cross tools for SH4 in /usr/local!

1