Win+SDCC+Eclipse HOWTO

Eclipse is a programming environment fairly popular among Java programmers. A set of plugins ("CDT") adds support for gcc-style compilers like SDCC. The combination was used to compile some C programs for MSX. In the following, a full step-by-step procedure is provided.

Note that in theory you can replace SDCC with your favourite C cross-compiler for MSX: z88dk/Hitech-C/etc., so experiment according to your personal taste.

Part I: install SDCC and run it from commandline

  • download latest version of SDCC binaries and documentation and install in a folder: for example "yourpath\sdcc"
  • download UnxUtils package, extract files make.exe, dd.exe, rm.exe, cp.exe and copy them into a new directory: "yourpath\sdcc\unxutils"
  • create directory "yourpath\sdcc\crt0msx" and put there the .rel and .asm startup files specific for MSX (you may have different startup files depending on the binary file you wish to create: ROM at 0x4000, ROM at 0x8000, COM, BIN etc. ...)
  • (this step is optional, needed only if you wish to have a  commandline prompt to use sdcc) create a batch file "yourpath\sdcc\sdcc-prompt.bat". This batch file will add sdcc and the unxutils directories to the default path, and can be used to compile from the command line:
    @echo off
    set SDCC_DIR="yourpath\Sdcc"
    set path=%path%;%SDCC_DIR%\bin;%SDCC_DIR%\unxutils
    cmd /k
  • double click on the batch file will open a command prompt window; if you type sdcc -v, make -version, dd --version will show version of respective programs

Part II: install Eclipse C/C++

  • download Java Runtime Environment (needed to execute Eclipse) and install it; note that if you already have a recent JRE installed (1.6.0 or more), you can safely skip this step
  • download zip package Eclipse IDE for C/C++ Developers and install in folder "yourpath\sdcc\eclipse\"
  • create shortcut "yourpath\sdcc\Eclipse SDCC" pointing to "yourpath\sdcc\eclipse\eclipse.exe"
  • create directory "yourpath\sdcc\eclipse_workspace"
  • your sdcc folder should now look like this:
    yourpath\sdcc>dir
    18/04/2010  02.26    <DIR>          .
    18/04/2010  02.26    <DIR>          ..
    18/04/2010  02.01    <DIR>          bin
    18/04/2010  02.41    <DIR>          crt0msx
    17/04/2010  22.59    <DIR>          doc
    18/04/2010  01.14    <DIR>          eclipse
    17/04/2010  23.46               853 Eclipse for SDCC.lnk
    18/04/2010  01.19    <DIR>          eclipse_workspace
    17/04/2010  22.57    <DIR>          include
    17/04/2010  22.57    <DIR>          lib
    17/04/2010  22.57    <DIR>          prog
    14/02/2007  23.51               105 sdcc-prompt.bat
    18/04/2010  02.19    <DIR>          unxutils

Part III: configure an Eclipse project for SDCC

  • double click the "Eclipse for SDCC" shortcut. Eclipse will ask for a default workspace, provide "yourpath\sdcc\eclipse_workspace", check "use this as default and do not ask again", proceed
  • create a new project: C Project > Makefile project > Empty project > --Other Toolchain--
  • in the Project > Properties > C/C++ Build > Environment, add variable PATH vith value ${Path};..\..\bin;..\..\unxutils
  • in the project create a new C file main.c and a new makefile; in the makefile you will be allowed to call sdcc, dd, rm, cp thanks to the PATH variable you have set in the previous step
  • in the Project > Properties > C/C++ General > Paths and Symbols > Includes > GNU C, add path ../../../sdcc/include
  • download and expand in your eclipse_workspace directory my Eclipse+SDCC sample project. The original project name is "prova".

Appendix A: files for directory "crt0msx"

SDCC comes with a default crt0.rel file good for a generic Z80 machine, but it doesn't work properly with our beloved MSX. Avelino's SDCC web page provides some asm/rel files that can be used  instead of the default crt0.rel. I collected several crt0 alternatives in this zip file, choose your favourite!

Appendix B: if you already have an Eclipse installed

Part II of the tutorial installs a copy of Eclipse that is private to  your MSX projects. I thought it was a cleaner solution, even if you already have your Eclipse Java installation.

If you want to have just one Eclipse, and you want to extend it to manage also SDCC projects, there's some hint.

  • follow tutorial Part I, no differences here
  • then go to Help > Install New Software> Work with and add the addres http://download.eclipse.org/tools/cdt/releases/galileo, then download all the CDT packages
  • follow tutorial Part III, but you will probably wish to use absolute paths to "yourpath\sdcc\..." where I configured relative paths