GCC for RISC OS

GCC for RISC OS is a complete, free and fully-featured compiler solution for RISC OS based on the GNU Compiler Collection. It can compile C and C++ using modern standards and assemble ARM code. It also includes support for RISC OS modules, and usage of the native RISC OS Shared C Library, or the bundled Unix-compatibility library UnixLib as runtime library. It aims to be feature complete above and beyond the commercial RISC OS Open Ltd's C/C++ compiler suite.

There also exist front ends for other languages, such as Fortran, Objective C, Ada 9X, Modula-2, Pascal, Cobol and Java, however these have not been ported to run on RISC OS at this time. Some of these are present, but unsupported, in older versions of RISC OS GCC.

The current version of GCC for RISC OS is 4.7.4 release 2 which is based on the ELF Object format and binutils. Previous releases were based on GCC 3.4 and targeted the traditional RISC OS AOF and AIF targets.

GCCSDK is a cross-compile environment that permits compiling of RISC OS programs under other Unix-like operating systems, taking advantage of the speed and tools available on those platforms. It is also able to cross-compile a large body of ported software, and easy porting of new packages and libraries. See its documentation for more details.

Using GCC under RISC OS

Prerequisites

An APCS-32 supporting Shared C Library (version 5.17 or later) is required to run GCC. This means that only pre-RISC OS 4.39 (Select 3i4) users need an update of their Shared C Library which they can get from RISC OS Open, see below. All later versions of RISC OS have this prerequisite fulfilled.

Download

GCC is very easy to set up on RISC OS. It is available via PackMan as a package from riscos.info and this will automatically take care of all dependencies on other packages. It can also be
downloaded directly and unpacked manually but here you need to take care of loading and unpacking all necessary dependencies yourself.

RISC OS GCC Tutorials and information

In addition, the !GCC application itself contains a number of examples (inside !GCC.Examples).

Distributing GCC compiled programs

GCC can compile programs using either the SharedCLibrary or UnixLib as runtime libraries. In case UnixLib runtime library is used as shared library, additional requirements are needed to run the distributed program.

SharedCLibrary

When you distribute a GCC compiled program and are using the SharedCLibrary as runtime library (i.e. using option -mlibscl), then no additional support files generally need to be made available with your program.

GCC does produce code which requires an APCS-32 supporting version of the SharedCLibrary (version 5.17 or later), however, so you should check (in the !Run file) that your user has a suitably up-to-date version installed. See the !System download for recent versions of SharedCLibrary suitable for RISC OS versions prior to RISC OS 4.39 (Select 3i4).

Note that all new RISC OS platforms ship with a sufficiently up-to-date version of the module present already.

UnixLib

When you are using UnixLib as runtime library (and that's the default runtime library), then an up-to-date version of some UnixLib support modules need to be used together with your program. The following is an overview of these support modules :

(Deprecated) !UnixHome application (typically required by some ported Unix programs wishing to store configuration files and settings in the Unix user's home directory) : !UnixHome. The !UnixHome application should be 'seen' by the RISC OS Filer before they can make use of it. Most applications will instead fall back to using standard RISC OS Choices paths in the absence of !UnixHome, and this is generally more desirable.

The modules SharedUnixLibrary, Digital Renderer, Iconv and CryptRandom will be RMEnsure'd with their minimal needed version number by the UnixLib code at the moment their functionality is needed. Error message will be returned when these modules are not available or are too old, so programmers don't need to RMEnsure those module versions.

When you distribute a copy of these UnixLib support modules with your program, please also mention the URLs in documentation and/or installation notes or program where up-to-date versions can be found.

Shared libraries

When the built program is using shared libraries, a copy of the shared libraries is needed to run the program. Instead of distributing the shared libraries together with your program, we strongly recommend to refer to the following URLs where the latest up-to-date copy of the shared libraries can be found:

Useful programs

The following list contains useful programs helping you to develop with GCC on RISC OS :

Sourcery : Sourcery will manage the source code that makes up a project but it will also manage the various resources files that are required to produce a RISC OS application. These include Sprite, Message and Template files.

ProfileMod : ProfileMod can be used to profile your code at expense of having to recompile it with the GCC option -finstrument-functions.

dmalloc port : dmalloc can be used to find memory leaks or memory corruptions due to wrong malloc()/free()/etc. use. It has been ported to RISC OS and is currently located in GCCSDK Autobuilder in the develop/dmalloc subdirectory.