[an error occurred while processing this directive] Node:Cross-DJGPP, Next:, Previous:Upload, Up:Miscellany

22.9 DJGPP as cross-compiler

Q: I want to use DJGPP as a cross-compiler for Motorola 68K targets. How should I proceed about this?

Q: I want to build GCC as a Unix-to-DOS cross-compiler. What should I do?

A: If you want a cross-compiler for m68k on a DOS machine, you need DJGPP configured as host=i386-go32, and target=m68k-coff. Such a package is already available. The binaries there are based on GCC 2.7.2. This package is reportedly no longer supported, but if you have questions about it, you can send them to Jim Karpinski. You can also try to contact Kai Ruottu, who is the provider of DOS-hosted gcc-m68k. Note that this package has only basic support for C++: the compiler is included, but the libraries, including libstc++ and libg++, and the C++ headers are missing, so even cin and cout don't work.

A Win32-hosted gcc-m68k is another possibility. It was created by David Fiddes. The Cygwin port of GCC can also be configured as a cross-compiler with m68k as the target. See the description of the Cygwin project, for more details about the Cygwin port. Object Software Inc. is a company that supports cross-builds based on GCC and DJGPP. Pre-built binaries of the compiler and some minimal development tools are available from this site for m68k, PowerPC, and Hitachi's SH-3 targets, all based on DJGPP v2. The CrossGCC FAQ, available from the same site, includes detailed instructions for building a cross-compiler for any target.

DJGPP can be built and installed as a cross-compiler running on a Unix machine and targeting DOS/Windows platforms. Detailed instructions for doing this on Linux can be found in the DJGPP HOWTO Repository. Here is the summary of the necessary steps to do that:

  1. Download the cross-compiler toolkit v2/djcrx203.zip from the usual DJGPP sites.
  2. Unpack djcrx203.zip on the Unix machine using unzip -a.

    You must use the -a switch, to force unzip to convert any DOS-style text file with CR-LF pairs at the end of each line to Unix-style text files. If you don't, things will break for you.

    unzip is available in source form from many FTP sites. Linux systems generally come with unzip, but if your system doesn't, download the sources and build it.

  3. Link or move the files in the cross directory to the top-level directory, where you unzipped djcrxNNN.zip.
  4. Download the latest GCC and Binutils distributions from your favorite GNU FTP site.

    The main GNU site is at ftp.gnu.org.

  5. Unpack GCC and Binutils from the same directory where you unzipped djcrxNNN.zip.
  6. You might need to edit the Makefile, either to choose an installation directory as appropriate for your machine, or to change the names of the directories where the GCC and Binutils distributions are unpacked (e.g., because their version numbers are different from those for which the Makefile was prepared).
  7. Follow instructions in the file cross/install that was unpacked from djcrx203.zip to build and install the cross compiler.

The cross-compiler you build is installed as dos-gcc, so to compile programs with it, use dos-gcc rather than cc or gcc, or set CC=dos-gcc when invoking Make.

The file cross/readme has some usage info for dos-gcc. It is generally correct, except that the version numbers for the various packages might not be up to date. You should always use the latest releases of every package.

Another alternative is the build.cross script included in the source distribution of the DJGPP port of GCC, gccNNNs.zip. This script was tested on GNU/Linux systems, and it allows to build GCC as a cross compiler hosted on a GNU/Linux system whose target is DJGPP-supported platforms. To use this script "out of the box", you will need to take care of some preliminaries:

Here, prefix is the root of your cross-development installation, usually /usr or /usr/local.

[an error occurred while processing this directive]