How to use the GCC Compiler


The GCC compiler (Gnu C Compiler) is written by the GCC team of the Free Software Foundation. The lastest version of GCC is 4.6. The last version of GCC for AmigaOS 3.x is 2.7.x, and the current version for Amiga OS 4.x is 4.2.4

Contents of GCC Package:

GCC for Amiga OS 3.x is available on Aminet,.
GCC for Amiga OS 4.x is available from the SDK.
The GCC is available in multiple parts depending on the operating system.


Download the GCC packages from Aminet.

gcc270-src.lha (optional)

gcc-bin.lha = GCC v2.7.2.1 update
gcc-src.lha = GCC v2.7.2.1 source update

gcc-faq_0.7.lha - Useful frequently asked questions about GCC.

Start with the base install and follow with installation C/C++ (cp) packages and the remaining parts.
You will need to set your shell stack to at least 50k e.g. stack 50000 to use gcc.

Directories and folders

An GCC installation contains a number of directories and assigns needed for it to run.

gcc - main directory (or sdk for Amiga OS 4 gcc)
include - Header files for gcc
documentation - developer, library, autodocs
bin - gcc program files

GCC Main Programs

gcc - Main compiler program (C programs)
as - Assembler
cpp - C Pre-processor
g++ - C++ compiler
gas - GNU Assembler
gasp - GNU assembler preprocessor
gdb - GNU debugger
gperf - GN perfect hash function generator
make - Compile and build GNC C projects

How to create an GCC Project

1. Open a Shell and make sure stack is set high enough e.g. stack 50000.

2. Create a new folder for your directory e.g. makedir Work:MyProject and cd to it.

3. Use Ed or your favourite editor (notepad) to create your source code e.g. notepad program.c

4 To compile a single program, enter gcc program.c -o program or g++ program.c -o program for C++ programs.

If you do not specify the -o option then the resulting program will be called a.out. If you forget the -o option, you can rename the a.out file to a more meaningful name.

To include the OS library functions and recognise Interface names, add the -lauto option at the end of the compiler command.

You can specify multiple options with vc (see the vbcc documentation on what the options are). If there are too many options

then use the -cmd option and use a file with all the options specified in it. GCC will compile using the ixemul.library, if you want to avoid using it, then use the -noixemul

option, and link with libnix instead to keep programs small and more Amiga-friendly.

5. To test your program type the program name e.g. program.

How to use make and makefiles

You can create a make file for each project. The all section describes the resulting program name, the next lines describe how to create the program and the object. The clean
section allows you to run make clean to recompile from scratch if necessary. the command line (gcc) on next line preceeded by a TAB character, or use a semi-colon and have the
command on the same line as the rule. Just type make to compile your project.If you need to debug, add the -g option before -lauto, then you can run gdb myprogram to run and debug the program safely.

all: myprogram
myprogram: myprogram.o   ; gcc -o myprogram myprogram.o -lauto
myprogram.o: myprogram.c ; gcc -c myprogram.c
clean: ; delete myprogram.o myprogram

More information on makefiles can be found on the GCC and Make page.

Back to Contents