[ previous ] [ Abstract ] [ Copyright Notice ] [ Contents ] [ next ]

Free H8 development environment under Linux
Chapter 2 Installing GCC, Binutils and Newlib


2.1 Getting Source

First of all, you must get source of GCC, binutils, and Newlib. Perhaps these are easily found, in a web/ftp site, or a CD-ROM. In this document, gcc-2.7.2.3, binutils-2.9.1 and newlib-1.7.1 are used.

After getting source package, unpack them. We assume that they are unpacked to /usr/local/src/.


2.2 Binutils Installation

To compile binutils, run configure and make.

     ./configure --target=h8300-hms --prefix=/usr/local
     make all
     make install

h8300-hms is a target identifier for H8. When you install other target CPU (such as SH-2), it must be replaced to another keyword. You may install it to any directory.

Now, assembler and linker is installed in your PC. Names of them begin with h8300-hms- , for example, as for H8 is h8300-hms-as.


2.3 GCC Installation

To compile GCC, run configure script first. Specify same options specified in binutil installation.

     ./configure --target=h8300-hms --prefix=/usr/local

In the prefix option, you must specify same directory as specified for binutils.

Unfortunately, makefile generated by the configure script must be modified slightly for H8. Two option must be added, the one is -Dinhibit_libc and the other is -mh. The former option is to compile without standard library, and the latter is to enable H8/300H instructions. Search the line where LIBGCC2_INCLUDES is defined in Makefile, and add these options like:

     LIBGCC2_INCLUDES = -Dinhibit_libc -mh

Then, execute make command. At this point, only C compiler ( not C++ ) can be made. To avoid making C++ compiler (and stopping by error), LANGUAGES=C option must be specified.

     make LANGUAGES=C all
     make LANGUAGES=C install

Next, you must replace float.h to the one in the normal compiler (the one in your linux distribution). Normally, representation scheme of floating point in the host CPU is different from that of target CPU, then GCC disables floating point features. But in this case, it is not a problem because H8 does not contain FPU and rely on the software FPU emulation library. Then copying float.h of host CPU to that of target CPU, floating point features are enabled. To do this, copy this file as follows. Modify directories in the following example for your system.

     cp /usr/lib/gcc-lib/i386-linux/2.95.2/include/float.h
     /usr/local/lib/gcc-lib/h8300-hms/2.7.2.3/include/float.h

If everything goes, GCC for H8 (h8300-hms-gcc)is installed. You can compile simple C source. ( Perhaps an error is occured while linking stage. )


2.4 Newlib Installation

Newlib is also easily installed by configure and make, by specifying same option used before.

     ./configure --target=h8300-hms --prefix=/usr/local
     make all
     make install

That's all. By newlib, you may use math functions and string functions, including sscanf. File I/O and time support functions cannot be used, because they are related to hardware. Of cource, OS support functions (such as process I/O functions) cannt be used too.


2.5 G++ Installation

If you intend to use C++ language, now compile it. In GCC source directory, run make as follows.

     make all
     make install


2.6 If Something Goes Wrong

`no such 386 instruction' error is occured when compiling GCC
You must install gcc to the same directory as binutils. To do this, you must specify prefix option to configure script explicitly, because default directory of GCC is different from that of binutils.

`stdio.h: No such file or directory' error is occured when compiling GCC
Normally, make makes C, C++, Objective-C compilers simultaneously. But, to make C++ and Objective-C compiler, standard C library is needed. If you intend to use C++ or Objective-C, they must be compiled after Newlib is installed.

`#error float.h values not known for cross-compiler' error is occured when making Newlib
Replace float.h. See GCC Installation, Section 2.3.


[ previous ] [ Abstract ] [ Copyright Notice ] [ Contents ] [ next ]
Free H8 development environment under Linux
version 1.0, 24 Nov 1999
Muneyuki IWATA kp9m-iwt@asahi-net.or.jp