Home page  | Downloading  | QL & compatible computers  | QDOS & compatible OS  | What monitor for a QL or compatible system ?

qdos-gcc howto


o What is qdos-gcc ?

This is a gcc cross-compiler for Linux (should work under other UNICES as well) which is able to generate QDOS/SMS executables. Only the cc front-end (gcc), the pre-processor (cpp) and the compiler phase (cc1) are actually gcc-specific. Some C68 utilities (as68, ld and slb) are still used by qdos-gcc so to generate the final QDOS/SMS binaries. The libraries that qdos-gcc may use are all the existing (unmodified) C68 libraries, but the main library (libc_a) had to be adapted slightly so that its (excellent and fast) math routines could be used by qdos-gcc.

The qdos-gcc project is maintained by:

In fact this project arose from the many messages exchanged through the ql-users mailing list. Richard and I both agreed (this is so rare we agree on something that this must indeed be noticed ;-) that QDOS/SMS was lacking a C/C++ compiler able to generate really fast code; this point of view was warmly seconded by a few other well known QLers. A few weeks after the messages were exchanged, Richard sent us the first gcc patch: qdos-gcc was born !

o Why should I use qdos-gcc ?

The QDOS/SMS systems already have an excellent C compiler: C68. This compiler is small (c68, the compiler phase, is less than 140Kb), ANSI C compliant, fast, and generates small and reasonably fast code.

On the other hand, most of the other operating systems have got gcc which is big (cc1, the compiler phase, is over 1.5Mb) but generates much faster code and can deal with C++, Objective C and Java as well (qdos-gcc is not yet ready to deal with these languages though).

Another thing to consider is that qdos-gcc being a cross-compiler, you can take benefit of all UNIX utilities (such as GNU make, autogen, autoconf and automake which are used in most major projects) that have not (yet) been ported to QDOS/SMS. Porting a C-written software to QDOS/SMS is therefore made easier (no more manual generation/editing of the makefile/config.h/etc... files !).

The last argument in favour of a cross-compiler is the compiling speed benefit for those who are running this cross-compiler on a hardware which is faster than their QL-compatible computer/QL emulator (compiling the whole libc.a on a Core-i5 at 4.6GHz only takes 7 seconds... and that's only using one core among four, since the library can't be compiled with "make -j4").

o And what speed gain over c68 compiled software can I expect ?

This is of course dependant on the compiled software and on the plateform you run it on... Here are some results of tests I made on a QXL (with a full blown 68040):

o OK, you convinced me !  Now how to install qdos-gcc ?

The prerequisit is to have a running Linux (or UNIX) system with a shell account, GNU make, sh (bash2 preferred), tar (bzip2 aware), bzip2, and a native gcc v2.95/2.96 compiler with associated utilities (as, ld, etc..., usualy known as "binutils") and development libraries. Note that the sources for gcc v2.95 will fail to compile with v3 and newer gcc versions (but most Linux distributions do provide older gcc compilers such as v2.96 or v3.3.6, often in a "contrib" or extended packages repository).

  1. First you will need the following files (the next instructions expect to find them into your HOME directory):

  2. Do make sure that the default compiler on your system is gcc v2.95:
              $ gcc --version

    You should get v2.95.x or v2.96 as a reply. If you get v3 or larger versions, your default compiler is not properly configured: check the documentation for your distribution to learn how to choose the right compiler (for example, in Mandriva and its clones, it's done with "update-alternatives --config gcc").

  3. Next you can untar everything in a safe place, say /usr/src/qdos, from a shell prompt type:
              $ mkdir /usr/src/qdos
              $ cd /usr/src/qdos
              $ tar xjf ~/gcc-core-2.95.3.tar.bz2
              $ tar xjf ~/qdos-gcc-utils-v2.tar.bz2
              $ tar xjf ~/libc-4.24.5.tar.bz2
  4. Don't forget to patch the gcc-core sources:
              $ cd gcc-2.95.3
              $ bzcat ~/qdos-gcc-diff-091000.bz2 | patch -p1 -s
              $ bzcat ~/gcc-2.95.3-bufixes.patch.bz2 | patch -p1 -s    (*)
              $ cd ..

    (*) Optional.

  5. Now you must compile and install the qdos-gcc utilities:
              $ cd qdos-gcc-utils
              $ make
              $ make install
              $ cd ..
  6. You will also need the C68 include files IOT compile qdos-gcc, so install them:
              $ cd libc-4.24.5
              $ make install-includes
              $ cd ..
  7. It's time to compile the qdos-gcc cross-compiler:
              $ mkdir build-qdos-gcc
              $ cd build-qdos-gcc
              $ ../gcc-2.95.3/configure --target=qdos
              $ make
              $ make install
              $ cd ..
  8. Some adjustments have to be made (else libgcc.a may not link properly), this is dealt with thanks to a script in qdos-gcc-utils (the script will also tidy-up some useless files and add some useful soft links):
              $ ./qdos-gcc-utils/scripts/post-gcc-install
  9. Now we can build and install the libc.a v4.24.5 library:
              $ cd libc-4.24.5
              $ export PATH=/usr/local/qdos/bin:$PATH     (*)
              $ make install
              $ cd ..

    (*) This line ensures that qdos-gcc will find the proper cpp executable: modern cpp's may fail to produce a gcc-v2.95-compatible output, which would cause a compilation failure...

That's it !  qdos-gcc is installed and ready... You will find qdos-gcc utilities and scripts into /usr/local/qdos/bin, while the C68 include files reside in /usr/local/qdos/include and the C68 libraries into /usr/local/qdos/lib. The qdos-gcc compiler itself resides in /usr/local/lib/gcc-lib/qdos/2.95.3 and some useful soft links are setup into /usr/local/bin (which should be part of your shell PATH variable). Note that when compiling programs using qdos-gcc, you must add a -lgcc option to the ld parameter list.

o Known bugs and incompatibilities:

^ Top of page.

(c) 2000, Thierry Godefroy. No warranty or whatsoever is given regarding the accuracy of the information contained in these Web pages.
<-  Back to home page.