Cross compile for 68000 in C under Windows

This article contains my notes for setting up a m68k cross-compiler using Cygwin. It’s all free software and gives me a way to create binary images for a 68000 CPU from C code on Windows. Here’s the step-by-step to set it up:

Step 1. Install Cygwin

Go to http://www.cygwin.com/ and download setup.exe. Run it.

During the setup, you will have the opportunity to select what packages to install. Choose the following:

  • binutils
  • gcc-core
  • bzip2
  • flex
  • make

Step 2. Download the compiler source code

You want binutils and gcc-core from GNU. Go to the GNU download page, choose a mirror and download the following files. Place them in your Cygwin home directory.

  • binutils-2.15.tar.bz2
  • gcc-core-3.4.2.tar.bz2

Yes there are more up-to-date versions but at the time of writing, the latest gcc versions do not support the 68000 platform. Feel free to try different versions but I know the versions just mentioned will work.

Step 3. Compile and install binutils

Launch Cygwin and type the following commands. Typing this kind of stuff is automatic for me these days. Its a pretty standard GNU setup procedure.

mkdir /usr/local/m68k

tar jxvf binutils-2.15.tar.bz2

cd binutils-2.15/

./configure --prefix=/usr/local/m68k --target=m68k-coff

make install

Step 4. Compile and install gcc

Same again for the C compiler.

cd ~

export PATH=$PATH:/usr/local/m68k/bin

tar jxvf gcc-core-3.4.2.tar.bz2

cd gcc-core-3.4.2/

./configure --prefix=/usr/local/m68k --target=m68k-coff --enable-languages=c

make install

Step 5. Set up your path

The 68000 compiler will be located in /usr/local/m68k/bin. To make life easier, you might like to add the following to your ~/.bashrc file:

export PATH=$PATH:/usr/local/m68k/bin

Step 6. Enjoy

Here’s the command to compile some C code:

m68k-coff-gcc -o test.out test.c

And the command to create a binary image from the compiled code:

m68k-coff-objcopy -O binary test.out test.bin

9 thoughts on “Cross compile for 68000 in C under Windows

  1. When I follow the steps in the link, when I get to the point of “make install” for the binutils I get the error:

    Entering directory ‘/home/Doug/binutils-2.15/bfd’
    *** No Rule to make target ‘install’. Stop.

  2. > Entering directory ‘/home/Doug/binutils-2.15/bfd’
    > *** No Rule to make target ‘install’. Stop.
    Beside that you need the package utils/diffutils additionaly, try the following procedure to build binutils:

    mkdir /usr/local/m68k
    tar jxvf binutils-2.15.tar.bz2
    cd binutils-2.15/
    mkdir ../binutils-build
    cd ../binutils-build
    ../binutils-2.15/configure –prefix=/usr/local/m68k –disable-nls
    make configure-host
    make LDFLAGS=”-all-static”
    make install
    make -C ld clean
    make -C ld LDFLAGS=”-all-static” LIB_PATH=/usr/local/lib

    Found at: http://oss.erdfunkstelle.de/lfs-de/6.0/online/chapter05/binutils-pass1.html

  3. Just a little detail: When I tried to install bintutil (at least), it would not do the make install (after ./configure), before I had executed make manually to build the package.

  4. I’m not sure. I haven’t done anything with 68000 software for nearly a year. The only thing I can think of is to check that the versions of binutils, gcc etc. are the same as those mentioned in the instructions.

  5. make install ….didnt work for me either on my fresh install of cygwin. i had to do a “make” first and then “make install” worked ok.

    Many Thanks Adam this page was a life saver and its gr8 information.

  6. When I follow the steps in the link, when I get to the point of “make” for the “gcc-code-4.2.4″ I get the error

    :unrecognized option `-mc68020′

  7. Hi Adam,i cant run the command tar jxvf binutils-2.15.tar.bz2.since i have placed binutials-2.15.tar.bz2 n the home directory but its showin that cannot open:no such file or directory.
    please help..

  8. Hi Adam, i have followed all the steps as you have mentioned but when i am goin to run hydra command there is a error message says:cygwin.dll is missig what do i do please help i have already install cygwin several times.

Comments are closed.