Please consider a donation to the Higher Intellect project. See https://preterhuman.net/donate.php or the Donate to Higher Intellect page for more info.

Installing and Using GCC: Difference between revisions

From Higher Intellect Vintage Wiki
 
(One intermediate revision by the same user not shown)
Line 520: Line 520:
As the message suggests, if you put your mouse over the message "<tt>press and die</tt>" and click the left mouse button, the program exits.
As the message suggests, if you put your mouse over the message "<tt>press and die</tt>" and click the left mouse button, the program exits.


==Troubleshooting==
===GCC 3.0.4 - SGI Freeware (Non-Nekoware)===
<pre>
ld32: FATAL 9: I/O error (/usr/lib32/mips3/crt1.o): No such file or directory.
</pre>
You haven't installed all the necessary pieces from the Development Libraries CD. Specifically: /usr/lib32/mips3/crt1.o is in the dev.sw.lib subsystem on that CD or equivalent.
<pre>
file.c:1: stdio.h: No such file or directory
</pre>
You haven't installed the IRIX standard headers. You may find them in IRIX inside irix_dev.sw.headers or in the compiler/development CD in compiler_dev.hdr.lib.
<pre>
/usr/include/string.h:67: warning: conflicting types for built-in function `memcpy' (or memcmp/memset/strlen)
</pre>
When you compile with the -mips3 option you should suppress the gcc builtins i.e.:
* gcc -fno-builtin -mips3 ...
'''Assembler messages:'''
<pre>
Fatal error: No compiled in support for 64 bit object file format
</pre>
You're running gcc 2.8.1 in 64-bit mode (gcc -mabi=64) but using the GNU assembler which doesn't support the 64-bit abi. Make sure that as in your PATH is the SGI assembler rather than the GNU assembler. You may rename the GNU assembler to gas to prevent this.
<pre>
as: unrecognized option `-n32'
</pre>
Again, you're running the GNU assembler rather than the SGI assembler.
The most probable reason is that you have an older version of the GNU compiler (gcc 2.7.x) and binutils installed in your PATH (/usr/freeware/bin/as or /usr/gnu/bin/as). To verify this run gcc with the -v option and see which assembler (as) is being called. Two possible fixes:
* Rename the gnu assembler under /usr/freeware/bin or /usr/gnu/bin to gas (best if you still want to keep gcc 2.7.x and the o32 ABI GNU capability)
* Remove the old GNU as altogether.
<pre>
ld: FATAL 43: cannot mix PIC and non-PIC: ...
</pre>
You are trying to mix PIC and non-PIC code, most probably by an incorrect use of -Bstatic. Note that on new IRIX systems, archives (.a files) are not statically linked objects but archives of dynamically linked objects. People tend to say "I want static linking" when they actually mean: "I want to use a .a library instead of a .so library."
Anyway: the correct way of mixing statically linked code with dynamically linked code is to alternate the mode of linking between libraries. Here's an example of the correct way to link with the GTK+ libraries:
<pre>
  gcc -o foo foo.o
        -L/path/to/gtk/lib -Wl,-B,static -lgtk -lgdk -lglib
        -Wl,-B,dynamic -lXext -lX11 -lm
</pre>
Note the switching between dynamic linking (default) to static linking with some freeware libraries (-lgtk -lgdk -lglib) and back to dynamic linking with the SGI X11 and libm libraries.
<pre>
ld: FATAL 9: I/O error (-lc): No such file or directory
ld: FATAL 9: I/O error (-lm): No such file or directory
</pre>
Basically: the linker cannot find your standard C (or math) library. The reasons may vary. You may be on a IRIX 6.2 system but you haven't installed the n32 libraries (eoe.sw32.lib for the IRIX CD.) This is the most common cause. Or you may be compiling with -mabi=64 but you don't have the 64-bit libraries installed on your system. You may otherwise have some bad settings for environment variables that affect the search for DSOs such as LD_LIBRARY_PATH, _RLD_ROOT, etc. See man dso. Try to run gcc with the -v option to see which linker is being called (e.g. does it get invoked with -n32 ?). This may help figuring out the problem
''Various strange errors running purify on gcc-compiled code?''
* Try installing patch 3944 or its successor.
====Known Bugs====
* Unlike the SGI cc, gcc does not support the o32 (old 32 bit) ABI.
* Unlike the SGI cc, gcc does not support 128-bit long double or (in FORTRAN) real*16 quantities.
* Gcc does not correctly pass/return structures that are smaller than 16 bytes and which are not 8 bytes. The problem is very involved and difficult to fix. It affects a number of other targets also, but irix6 is affected the most, because it is a 64 bit target, and 4 byte structures are common. The exact problem is that structures are being padded at the wrong end, e.g. a 4 byte structure is loaded into the lower 4 bytes of the register when it should be loaded into the upper 4 bytes of the register.


==Additional Resources==
==Additional Resources==

Latest revision as of 00:00, 2 August 2019

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.


Prerequisites[edit]

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

Correct Version of IRIX[edit]

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 and 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[edit]

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#Summary_by_MIPS_version 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
...
IRIS 2%

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[edit]

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.

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

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[edit]

For this example we will use the primary mirror at http://nekoware.dustytech.net/. 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 http://nekoware.dustytech.net/current
MIPS III nekoware-mips3 http://nekoware.dustytech.net/nekoware-mips3/current

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[edit]

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

Preparing the Packages[edit]

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-0.18.1.1.tardist  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
IRIS 6%

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 neko_gcc.man, 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.man  neko_ncurses.man
neko_gcc.man       neko_glib.man      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_libxml2.man   neko_zlib.man
neko_gettext.man   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)[edit]

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  neko_gcc.man.gcc [d]            1180+  gcc-3.4.6 man pages
  N  neko_gcc.man.info               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  neko_gcc.sw.java              117903+  gcc-3.4.6 java support, utilities
i N  neko_gcc.sw.utils [d]            471+  gcc-3.4.6 other languages,
                                            utilities

i N  neko_gettext.man.html [d]       3802+  HTML documentation
i N  neko_gettext.man.info [d]        717+  info pages
i N  neko_gettext.man.manpages [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  neko_glib.man.html             15916+  HTML Documentation
i N  neko_glib.man.manpages [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  neko_libiconv.man.doc [d]         45+  html documentation
i N  neko_libiconv.man.manpages [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  neko_libxml2.man.html           5721+  html documentation
i N  neko_libxml2.man.manpages [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  neko_ncurses.man.manpages [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  neko_zlib.man.manpages [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 

Inst>

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

Inst>

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 neko_gcc.man 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 neko_gettext.man 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 neko_glib.man 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 neko_libiconv.man 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 neko_libxml2.man 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 neko_ncurses.man 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 neko_zlib.man 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*
gettext.sh*                  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            libiconv.so.3.0
gcc/                      libgettextpo.la*          libintl.a
gettext/                  libgettextpo.so@          libintl.la*
gio/                      libgettextpo.so.1@        libintl.so@
lib-org-w3c-dom.a         libgettextpo.so.1.0*      libintl.so.4@
lib-org-w3c-dom.la*       libgettextpo.so.1.1*      libintl.so.4.0*
lib-org-xml-sax.a         libgettextsrc-0.17.so*    libintl.so.9@
lib-org-xml-sax.la*       libgettextsrc-0.18.1.so*  libintl.so.9.1*
libasprintf.a             libgettextsrc.la*         libintl.so.9.2*
libasprintf.la*           libgettextsrc.so@         libmenu.a
libasprintf.so@           libgio-2.0.la*            libmenu.so*
libasprintf.so.1@         libgio-2.0.so@            libncurses++.a
libasprintf.so.1.0*       libgio-2.0.so.1@          libncurses.a
libcharset.a              libgio-2.0.so.1.1*        libncurses.so*
libcharset.la             libglib-2.0.la*           libpanel.a
libcharset.so@            libglib-2.0.so@           libpanel.so*
libcharset.so.2@          libglib-2.0.so.1@         libxml2.a
libcharset.so.2.0         libglib-2.0.so.1.1*       libxml2.la*
libcroco-0.6.a            libgmodule-2.0.la*        libxml2.so@
libcroco-0.6.la*          libgmodule-2.0.so@        libxml2.so.3@
libcroco-0.6.so@          libgmodule-2.0.so.1@      libxml2.so.3.27*
libcroco-0.6.so.4@        libgmodule-2.0.so.1.1*    libxml2.so.3.8*
libcroco-0.6.so.4.1*      libgobject-2.0.la*        libz.a*
libffi.a                  libgobject-2.0.so@        libz.so@
libffi.la*                libgobject-2.0.so.1@      libz.so.1@
libform.a                 libgobject-2.0.so.1.1*    libz.so.1.2@
libform.so*               libgthread-2.0.la*        libz.so.1.2.3*
libgcj.a                  libgthread-2.0.so@        logging.properties
libgcj.la*                libgthread-2.0.so.1@      mabi=32/
libgcj.spec               libgthread-2.0.so.1.1*    mabi=64/
libgettextlib-0.17.so*    libiberty.a               pkgconfig/
libgettextlib-0.18.1.so*  libiconv.la               security/
libgettextlib.la*         libiconv.so@              terminfo/
libgettextlib.so@         libiconv.so.3@            xml2Conf.sh
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[edit]

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[edit]

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[edit]

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[edit]

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[edit]

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 linuxjunkies.org 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>

main(argc,argv)
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);

     XtRealizeWidget(toplevel);

     XtMainLoop();

}


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

     exit(0);

}

Compiling and Running simple.c[edit]

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.

Troubleshooting[edit]

GCC 3.0.4 - SGI Freeware (Non-Nekoware)[edit]

ld32: FATAL 9: I/O error (/usr/lib32/mips3/crt1.o): No such file or directory.

You haven't installed all the necessary pieces from the Development Libraries CD. Specifically: /usr/lib32/mips3/crt1.o is in the dev.sw.lib subsystem on that CD or equivalent.

file.c:1: stdio.h: No such file or directory

You haven't installed the IRIX standard headers. You may find them in IRIX inside irix_dev.sw.headers or in the compiler/development CD in compiler_dev.hdr.lib.

/usr/include/string.h:67: warning: conflicting types for built-in function `memcpy' (or memcmp/memset/strlen)

When you compile with the -mips3 option you should suppress the gcc builtins i.e.:

  • gcc -fno-builtin -mips3 ...

Assembler messages:

Fatal error: No compiled in support for 64 bit object file format

You're running gcc 2.8.1 in 64-bit mode (gcc -mabi=64) but using the GNU assembler which doesn't support the 64-bit abi. Make sure that as in your PATH is the SGI assembler rather than the GNU assembler. You may rename the GNU assembler to gas to prevent this.

as: unrecognized option `-n32'

Again, you're running the GNU assembler rather than the SGI assembler. The most probable reason is that you have an older version of the GNU compiler (gcc 2.7.x) and binutils installed in your PATH (/usr/freeware/bin/as or /usr/gnu/bin/as). To verify this run gcc with the -v option and see which assembler (as) is being called. Two possible fixes:

  • Rename the gnu assembler under /usr/freeware/bin or /usr/gnu/bin to gas (best if you still want to keep gcc 2.7.x and the o32 ABI GNU capability)
  • Remove the old GNU as altogether.
ld: FATAL 43: cannot mix PIC and non-PIC: ...

You are trying to mix PIC and non-PIC code, most probably by an incorrect use of -Bstatic. Note that on new IRIX systems, archives (.a files) are not statically linked objects but archives of dynamically linked objects. People tend to say "I want static linking" when they actually mean: "I want to use a .a library instead of a .so library." Anyway: the correct way of mixing statically linked code with dynamically linked code is to alternate the mode of linking between libraries. Here's an example of the correct way to link with the GTK+ libraries:

   gcc -o foo foo.o 
        -L/path/to/gtk/lib -Wl,-B,static -lgtk -lgdk -lglib 
        -Wl,-B,dynamic -lXext -lX11 -lm

Note the switching between dynamic linking (default) to static linking with some freeware libraries (-lgtk -lgdk -lglib) and back to dynamic linking with the SGI X11 and libm libraries.

ld: FATAL 9: I/O error (-lc): No such file or directory
ld: FATAL 9: I/O error (-lm): No such file or directory

Basically: the linker cannot find your standard C (or math) library. The reasons may vary. You may be on a IRIX 6.2 system but you haven't installed the n32 libraries (eoe.sw32.lib for the IRIX CD.) This is the most common cause. Or you may be compiling with -mabi=64 but you don't have the 64-bit libraries installed on your system. You may otherwise have some bad settings for environment variables that affect the search for DSOs such as LD_LIBRARY_PATH, _RLD_ROOT, etc. See man dso. Try to run gcc with the -v option to see which linker is being called (e.g. does it get invoked with -n32 ?). This may help figuring out the problem

Various strange errors running purify on gcc-compiled code?

  • Try installing patch 3944 or its successor.

Known Bugs[edit]

  • Unlike the SGI cc, gcc does not support the o32 (old 32 bit) ABI.
  • Unlike the SGI cc, gcc does not support 128-bit long double or (in FORTRAN) real*16 quantities.
  • Gcc does not correctly pass/return structures that are smaller than 16 bytes and which are not 8 bytes. The problem is very involved and difficult to fix. It affects a number of other targets also, but irix6 is affected the most, because it is a 64 bit target, and 4 byte structures are common. The exact problem is that structures are being padded at the wrong end, e.g. a 4 byte structure is loaded into the lower 4 bytes of the register when it should be loaded into the upper 4 bytes of the register.

Additional Resources[edit]

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[edit]

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[edit]

Resources at SGI[edit]

Other Resources[edit]