Installing and Using GCC

From Nekochan
Revision as of 17:43, 6 July 2017 by Legalize (Talk | contribs) (Remove redundant link)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

There have been repeated requests for a guide to getting the GNU Compiler Collection (GCC) installed on a new (or new to this owner) IRIX machine. The easiest way to accomplish this is to install the version maintained as part of the Nekoware project.


This section describes what you'll need before you can start installing or using GCC.

Correct Version of IRIX

Before you can install GCC (or any other Nekoware package) you have to be running IRIX 6.5.21 or later. Refer to the wiki page What Versions of IRIX Run on My SGI? to make sure your particular machine and configuration will support this version.

You must also have the IRIS Development Libraries installed. If you run the command versions compiler_dev and no packages are listed, you do not have the development options installed - see one of the "IRIX Installation" pages in the HowTo section of the wiki for details about how to add these packages.

Processor Architectures and Collections

Note that there are separate builds of Nekoware for MIPS III and MIPS IV family processors. MIPS IV processors can use the "current" collection of Nekoware, whereas the MIPS III processors must use the "nekoware-mips3" collection.

These processor families are fully documented on the MIPS Architecture wiki page, but generally speaking if your machine has an R4000-series processor it's MIPS III; if it has an R5000 or higher it's MIPS IV. If you aren't sure which processor your machine uses, run the hinv(1m) command and look for a line similar to the following:

IRIS 1% hinv
CPU: MIPS R5000 Processor Chip Revision: 2.1
FPU: MIPS R5000 Floating Point Coprocessor Revision: 1.0
1 200 MHZ IP32 Processor

In this example, the command has been run on an [O2] workstation fitted with a 200MHz R5000 processor, which is part of the MIPS IV family and so would be able to use the "current" collection.

Required Packages

The GCC package contains many files required to run the compiler, assemble machine code, and link executables. However it does not include the libraries needed to create executable programs. Exactly which libraries are needed will depend on what functions in which libraries you wish to use in your programs - there's no way to predict that in advance for a general-purpose document such as this.

The following is a list of the minimal set of packages required to be able to create simple programs with GCC. When you read this and check the repository, you may find that different version numbers are present. This is normal as packages are updated over time. In particular, you may see different versions or packages of GCC made available - this particular package was selected to make installation as straightforward as possible.


Note: If you are using the MIPS III collection, the version numbers you see may differ from those you would see in the MIPS IV collection. It should make no difference so long as all the indicated packages are installed from the appropriate collection.

Many users who have 9GB or more disk space on their system choose to install the entire Nekoware collection. A typical IRIX 6.5.22 installation may consume 2GB of space; as of August 2011, the entire "current" Nekoware collection takes up just over 6GB in "inst" form, that is, unpacked from their tardists. You may also want to check out DINA - see the Additional Resources section for more information.

Retrieving the Packages

You should check the main Nekoware page to find the mirror site closest to you, especially if transfers between your location and North America may not be the fastest option. However for this example we will use the primary mirror at Depending on which processor(s) are present in your system, you will find the necessary files in one of the following locations:

Nekoware Package Collections
CPU Family Short Name Location
MIPS IV current MIPS III nekoware-mips3

Note: If you are using the MIPS III collection, the version numbers may differ from those you would see in the MIPS IV collection. It should make no difference so long as all the indicated packages are installed from the appropriate collection.

It is beyond the scope of this document to provide a step-by-step guide to retrieving these packages. The reader is assumed to have transferred them to their IRIX system and placed them in the directory /var/tmp/nekoware.

Installing Packages

This section describes the steps to actually install the required packages on your system.

Preparing the Packages

Following earlier instructions, there should be a small number of files with the extension tardist in /var/tmp/nekoware:

IRIS 5% ls
neko_gcc-3.4.6.tardist         neko_libiconv-1.11.tardist
neko_gettext-  neko_libxml2-2.7.8.tardist
neko_glib-2.26.1-10.tardist    neko_ncurses-5.7.tardist
neko_libcroco-0.6.2-5.tardist  neko_zlib-1.2.3-r1.tardist

Each tardist file may contain five other files that need to be unpacked before they can be installed on your system. You'll need to unpack each of them in order to proceed. Here is an example of unpacking the neko_gcc-3.4.6.tardist file:

IRIS 10% tar -xvf neko_gcc-3.4.6.tardist
x neko_gcc, 3338 bytes, 7 blocks
x neko_gcc.idb, 465360 bytes, 909 blocks
x, 1965212 bytes, 3839 blocks
x neko_gcc.opt, 28249152 bytes, 55175 blocks
x neko_gcc.sw, 130456193 bytes, 254798 blocks
IRIS 11% 

After unpacking all the tardist files and removing them, you should see a listing similar to this:

IRIS 14% ls
neko_gcc           neko_glib          neko_libiconv.idb  neko_ncurses.idb
neko_gcc.idb       neko_glib.idb      neko_libiconv.opt  neko_ncurses.opt
neko_gcc.opt       neko_glib.opt      neko_libiconv.sw   neko_ncurses.sw
neko_gcc.sw        neko_glib.sw       neko_libxml2       neko_zlib
neko_gettext       neko_libcroco      neko_libxml2.idb   neko_zlib.idb
neko_gettext.idb   neko_libcroco.idb   neko_libcroco.opt  neko_libxml2.opt   neko_zlib.opt
neko_gettext.opt   neko_libcroco.sw   neko_libxml2.sw    neko_zlib.sw
neko_gettext.sw    neko_libiconv      neko_ncurses
IRIS 15% 

Running inst(1m)

Under IRIX, packages are installed and removed using the inst(1m) utility. It would be a good idea to read the manpage now and familiarize yourself with the program, but the following example shows all the necessary steps.

Note: Before you run the inst(1m) program, you must be acting as the superuser or root account, and make sure you are in the /var/tmp/nekoware directory or whichever directory the tardist files were unpacked in.

IRIS 5# inst -f .

Default distribution to install from: .

For help on inst commands, type "help overview".

Inst 4.1 Main Menu

 1. from [source ...]            Specify location of software to be installed
 2. open [source ...]            Specify additional software locations
 3. close [source ...]           Close a software distribution location
 4. list [keywords] [names]      Display information about software subsystems
 5. go                           Perform software installation and removal now
 6. install [keywords] [names]   Select subsystems to be installed
 7. remove [keywords] [names]    Select subsystems to be removed
 8. keep [keywords] [names]      Do not install or remove these subsystems
 9. step [keywords] [names]      Interactive mode for install/remove/keep
10. conflicts [choice ...]       List or resolve installation conflicts
11. help [topic]                 Get help in general or on a specific word
12. view ...                     Go to the View Commands Menu
13. admin ...                    Go to the Administrative Commands Menu
14. quit                         Terminate software installation

The list command will show which packages are available, and which have been automatically selected for installation:

Inst> list
Reading product descriptions ..  13% 
Reading /var/inst/hist
Reading product descriptions ..  25% 
Setting distribution to .
Reading product descriptions .. 100% Done.
  View:      distribution
  Status:    N=new, U=upgrade, S=same, D=downgrade
  Stream:    feature
  Selection: i=install, r=remove, k=keep

  Subsystem Types [bdroc]:  b=reBoot needed, d=Default, r=Required, o=overlay,
             c=Client only

i N [d]            1180+  gcc-3.4.6 man pages
  N               4138+  gcc-3.4.6 info pages
  N  neko_gcc.opt.dist                348+  gcc-3.4.6 distribution files
  N  neko_gcc.opt.relnotes              1+  gcc-3.4.6 release notes
  N  neko_gcc.opt.src               27533+  gcc-3.4.6 original source code
i N  neko_gcc.sw.gcc [d]           257866+  gcc-3.4.6 execution only env
  N              117903+  gcc-3.4.6 java support, utilities
i N  neko_gcc.sw.utils [d]            471+  gcc-3.4.6 other languages,

i N [d]       3802+  HTML documentation
i N [d]        717+  info pages
i N [d]    170+  man pages
i N  neko_gettext.opt.dist [d]        312+  distribution files
  N  neko_gettext.opt.patches           3+  source code patches
i N  neko_gettext.opt.relnotes [d]      2+  release notes
  N  neko_gettext.opt.src            7595+  original source code
i N  neko_gettext.sw.eoe [d]         8863+  execution only env
i N  neko_gettext.sw.hdr [d]          187+  header files
i N  neko_gettext.sw.lib [d]         5340+  shared libraries

  N             15916+  HTML Documentation
i N [d]        40+  man pages
  N  neko_glib.opt.dist               134+  distribution files
  N  neko_glib.opt.patches              7+  source code patches
i N  neko_glib.opt.relnotes [d]         2+  release notes
  N  neko_glib.opt.src                  0   original source code
i N  neko_glib.sw.eoe [d]            4805+  execution only env
i N  neko_glib.sw.hdr [d]            1364+  header files
i N  neko_glib.sw.lib [d]            4668+  shared library files

  N  neko_libcroco.opt.dist             9+  distribution files
  N  neko_libcroco.opt.relnotes         3+  release notes
  N  neko_libcroco.opt.src            326+  original source code
i N  neko_libcroco.sw.eoe [d]          39+  execution only env
i N  neko_libcroco.sw.hdr [d]         116+  header files
i N  neko_libcroco.sw.lib [d]        1137+  shared libraries

i N [d]         45+  html documentation
i N [d]    17+  man pages
  N  neko_libiconv.opt.dist            18+  distribution files
  N  neko_libiconv.opt.relnotes         2+  release notes
  N  neko_libiconv.opt.src           3517+  original source code
i N  neko_libiconv.sw.eoe [d]         109+  execution only env
i N  neko_libiconv.sw.hdr [d]          12+  header
i N  neko_libiconv.sw.lib [d]        1083+  shared libraries

  N           5721+  html documentation
i N [d]     21+  man pages
i N  neko_libxml2.opt.dist [d]         48+  distribution files
i N  neko_libxml2.opt.relnotes [d]      2+  release notes
  N  neko_libxml2.opt.src            2565+  original source code
i N  neko_libxml2.sw.eoe [d]          101+  execution only env
i N  neko_libxml2.sw.hdr [d]          444+  header files
i N  neko_libxml2.sw.lib [d]        11034+  shared libraries

i N [d]    843+  man pages
  N  neko_ncurses.opt.dist            436+  distribution files
  N  neko_ncurses.opt.relnotes          1+  release notes
  N  neko_ncurses.opt.src            1779+  original source code
i N  neko_ncurses.sw.arlib [d]       3148+  archive libraries
i N  neko_ncurses.sw.eoe [d]          215+  execution only environment
i N  neko_ncurses.sw.hdr [d]          298+  header files
i N  neko_ncurses.sw.lib [d]         1208+  shared libraries
i N  neko_ncurses.sw.terminfo [d]    3262+  terminfo files

i N [d]         5+  man pages
  N  neko_zlib.opt.dist                 3+  distribution files
  N  neko_zlib.opt.relnotes             3+  release notes
  N  neko_zlib.opt.src                416+  original source code
i N  neko_zlib.sw.hdr [d]              75+  header files
i N  neko_zlib.sw.lib [d]             299+  shared libraries

Disk space summary (Kbytes):            /

Current free space               65712927 
- Selections net change            313342+
- Temporary inst overhead            1473+
= Minimum free during install    65398112 

Final projected free space       65399585 


The next steps are to make sure that the automatically selected packages remain selected, and the rest of the packages in the directory are added to the list to be installed. Then the conflicts command is used to verify that the packages being installed don't depend on some other package that isn't being installed now, or hasn't been installed in the past. For example, if your system did not have the IRIS Development Libraries or IRIS Development Foundation installed, the conflicts command would report a number of unmet dependencies and the installation would not be able to continue.

Inst> keep * 

Inst> install *

Inst> conflicts
No conflicts


The command that will cause these packages to be installed is named go, and this is the next step in our process:

Inst> go
Reading fileset information ..   8% 
Pre-installation check ..  16% 
Checking space requirements ..  24% 
Pre-installation check completed
Installing/removing files ..  24% 
Installing new versions of selected subsystems
Installing new versions of selected neko_gcc.opt subsystems
Installing new versions of selected neko_gcc.sw subsystems
Installing/removing files ..  42% 
Installing new versions of selected subsystems
Installing/removing files ..  54% 
Installing new versions of selected neko_gettext.opt subsystems
Installing new versions of selected neko_gettext.sw subsystems
Installing/removing files ..  57% 
Installing new versions of selected subsystems
Installing/removing files ..  60% 
Installing new versions of selected neko_glib.opt subsystems
Installing new versions of selected neko_glib.sw subsystems
Installing/removing files ..  64% 
Installing new versions of selected neko_libcroco.opt subsystems
Installing new versions of selected neko_libcroco.sw subsystems
Installing new versions of selected subsystems
Installing new versions of selected neko_libiconv.opt subsystems
Installing new versions of selected neko_libiconv.sw subsystems
Installing/removing files ..  66% 
Installing new versions of selected subsystems
Installing/removing files ..  67% 
Installing new versions of selected neko_libxml2.opt subsystems
Installing new versions of selected neko_libxml2.sw subsystems
Installing/removing files ..  68% 
Installing new versions of selected subsystems
Installing/removing files ..  73% 
Installing new versions of selected neko_ncurses.opt subsystems
Installing new versions of selected neko_ncurses.sw subsystems
Installing/removing files ..  93% 
Installing new versions of selected subsystems
Installing new versions of selected neko_zlib.opt subsystems
Installing new versions of selected neko_zlib.sw subsystems
Installing/removing files ..  94% 
Removing orphaned directories
Running exit-commands ..  99% 
Checking dependencies .. 100% Done.
Installations and removals were successful.
You may continue with installations or quit now.

Inst> quit
Requickstarting ELF files (see rqsall(1)) .. 100% Done.
IRIS 6# 

That completes the installation process. If you're wondering what that last bit about "requickstarting" means, see the manual page for rqsall(1m).

If you look in the directory /usr/nekoware/bin you should see the following files:

IRIS 11# ls /usr/nekoware/bin
addr2name.awk*               jv-convert*
autopoint*                   jv-scan*
c++@                         mips-sgi-irix6.5-c++@
captoinfo@                   mips-sgi-irix6.5-g++@
clear*                       mips-sgi-irix6.5-gcc@
cpp*                         mips-sgi-irix6.5-gcc-3.4.6*
croco-0.6-config*            mips-sgi-irix6.5-gcj@
csslint-0.6*                 mips-sgi-irix6.5-gcjh@
envsubst*                    msgattrib*
g++*                         msgcat*
g77*                         msgcmp*
gcc*                         msgcomm*
gccbug*                      msgconv*
gcj*                         msgen*
gcjh*                        msgexec*
gcov*                        msgfilter*
gdbus*                       msgfmt*
gettext*                     msggrep**                  msginit*
gettextize*                  msgmerge*
gij*                         msgunfmt*
gio-querymodules*            msguniq*
glib-compile-schemas*        ncurses5-config*
glib-genmarshal*             ngettext*
glib-gettextize*             recode-sr-latin*
glib-mkenums*                reset@
gobject-query*               rmic*
grepjar*                     rmiregistry*
gsettings*                   tic*
gtester*                     toe*
gtester-report*              tput*
iconv*                       tset*
infocmp*                     xgettext*
infotocap@                   xml2-config*
jar*                         xmlcatalog*
jcf-dump*                    xmllint*
IRIS 12# 

Likewise if you check to see which libraries have been installed, you should see something similar to this:

IRIS 17# ls /usr/nekoware/lib
charset.alias             libgettextpo.a  
gcc/            *          libintl.a
gettext/        *
libasprintf.a   ***          libmenu.a *  *            libncurses++.a*          libncurses.a
libcharset.a    **   *           libpanel.a   *         libxml2.a**
libcroco-0.6.a  *******        libz.a*
libffi.a        *      
libform.a       **     **
libgcj.a        *            mabi=32/
libgcj.spec     *    mabi=64/*    libiberty.a               pkgconfig/*               security/*              terminfo/  
IRIS 18# 

At this point we no longer need superuser privileges, and we're ready to take the compiler out for a spin...

Using GCC

This section very, very briefly describes how you can make use of GCC once it has been installed. Note that we are no longer using the superuser or root account.

Setting Up The Environment

In order to run a program, your shell needs to be able to find it. As always, this is accomplished by using the $PATH environment variable. However the packages we just installed are not part of the typical IRIX file organization - they all get installed under /usr/nekoware, so we have to alter our environment a little bit to compensate.

Shell Commands
csh set path=( /usr/nekoware/bin $path )
setenv MANPATH /usr/nekoware/man:$MANPATH
setenv CFLAGS "-mabi=n32 -I/usr/nekoware/include -I/usr/include"
setenv LDFLAGS "-L/usr/nekoware/lib -L/usr/lib32"
setenv LD_LIBRARY_PATH /usr/nekoware/lib:/usr/lib32
ksh export PATH="/usr/nekoware/bin:$PATH"
export MANPATH="/usr/nekoware/man:$MANPATH"
export CFLAGS="-mabi=n32 -I/usr/nekoware/include -I/usr/include"
export LDFLAGS="-L/usr/nekoware/lib -L/usr/lib32"
export LD_LIBRARY_PATH="/usr/nekoware/lib:/usr/lib32"

You may need to adapt these settings for your system, depending on the version of IRIX and other software products that are installed. You may also wish to incorporate these changes into your .cshrc or .profile so that they will be set for you automatically each time you logon to the system.

A Painfully Simple Test Program

For an intial test of GCC we will use a slight variation on everybody's favorite C test program:

#include <stdio.h>

int main (int argc, char *argv[]) {

        printf("Hello, Nekochanners!\n");


Compiling and Running hello.c

Compiling a simple program like this is very straightforward:

IRIS 21% ls -lh
-rw-r--r--    1 root     sys           95b May 22 13:43 hello.c
IRIS 22% gcc hello.c
IRIS 23% ls -lh
-rwxr-xr-x    1 root     sys           42K May 22 13:43 a.out*
-rw-r--r--    1 root     sys           95b May 22 13:43 hello.c
IRIS 24% ./a.out
Hello, Nekochanners!
IRIS 25% 

A Simple X Windows Program

The following program is a very simple example of using the X Toolkit to build a program with a GUI. The sample code was appropriated from without permission.

 *                simple.c
 *  A very simple X program that uses the Athena
 *  widgets

#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <X11/Xaw/Command.h>

int argc;
char **argv; {
     Widget toplevel;
     Widget command;
     void quit();

     toplevel = XtInitialize(argv[0],"simple",NULL, 0,
                &argc, argv);

     command = XtCreateManagedWidget("press and die",
                commandWidgetClass, toplevel, NULL, 0);

     XtAddCallback(command,XtNcallback,quit, NULL);




void quit(w,client,call)
Widget w;
XtPointer client;
XtPointer call; {



Compiling and Running simple.c

Compiling a simple program like this is very straightforward:

IRIS 32% ls -lh
-rw-r--r--    1 root     sys          764b May 22 23:47 simple.c
IRIS 33% gcc -o simple simple.c -lXaw -lXt -lX11
IRIS 34% ls -lh
-rwxr-xr-x    1 root     sys           42K May 23 00:49 simple*
-rw-r--r--    1 root     sys          764b May 22 23:47 simple.c
IRIS 35% ./simple
IRIS 36%

This sample program doesn't write any output to the terminal window like hello.c did, but when run on your workstation this window should appear:


As the message suggests, if you put your mouse over the message "press and die" and click the left mouse button, the program exits.

Additional Resources

This section describes additional sources of information relevant to getting a development environment setup, or working with Nekoware in general.

deBug's IRIX Network Appliance

Nekochanner deBug has created a virtual machine image or appliance known as deBug's IRIX Network Appliance, or DINA, to make it easier to perform intallations of IRIX and Nekoware. If you have a non-SGI system that can run the free VMware Player - most Macs and PCs can - then you can use DINA.

DINA acts as a netboot server for SGI systems, and can also keep a local copy of the Nekoware collection up-to-date automatically. If you've ever sat in front of an SGI system swapping in CD after CD for inst(1m) to read, compare, then read again when actually installing packages, you'll appreciate that with DINA you'll never have to suffer through that process again.

You can learn more about DINA and obtain a copy of the VM image at the official DINA web site. The wiki page Using DINA For Network Installation of IRIX includes some tips to supplement the official DINA documentation; be sure to check the official site first, as these tips may have been incorporated by the time you read this.

Resources at Nekochan

Resources at SGI

Other Resources