[ Welcome | Crossroad | Humanae | Computer stuff ]
"Easy" installation of GNU C on HP-UX
You can find a pre-compiled Gnu C ready to be installed at
HP Porting centre
Read the text carefully and take a close look at the "Dependencies:" line.
gcc-2.7.2.1 includes all of the support for compiling C++ and Objective C,
including a run-time library for Objective C. It is *highly recommended*
that you use the Gnu assembler with Gnu C. It is available in the
binutils package. Obtain and install binutils before attempting to build gcc.
Also, you *must* install Gnu sed first, as the default sed is broken.
In this case when we are going to install the pre-compiled binaries (depot)
it is NOT necessary to have "sed" & "binutils" first, but here I do it
anyway.
Preparations
Login as root:
# mkdir /install/gnu (or wherever you want)
# cd /install/gnu
Download
Download the Statically Linked Binary (gzipped) "sed", "binutils" & "gcc"
NOTE ! Installing Gnu C from a depot-file like this, will install
C++, Objective C & run-time library for Objective C. If you want
C++ only (i.e. low on diskspace) you should download the source code
& install Gnu C the "hard" way.
NOTE ! Sometimes it seems that a downloaded Gnu-zipped does not get the
extension ".gz" ! Add the ".gz" extension:
# mv binutils-2.7-sa-10.10.depot binutils-2.7-sa-10.10.depot.gz
# mv gcc-2.7.2.1-sa-10.10.depot gcc-2.7.2.1-sa-10.10.depot.gz
# mv sed-2.05-sa-10.10.depot sed-2.05-sa-10.10.depot.gz
# gunzip *.gz
Install
# swinstall -s /install/gnu/sed-2.05-sa-10.10.depot sed
# swinstall -s /install/gnu/binutils-2.7-sa-10.10.depot binutils
# swinstall -s /install/gnu/gcc-2.7.2.1-sa-10.10.depot gcc
Configure
Now the software is installed but there is no PATH pointing at them.
# vi /etc/PATH
Add "/opt/gcc/bin:/opt/sed/bin:/opt/binutils/bin:" first
of all.
# vi /etc/MANPATH
Add ":/opt/gcc/man:/opt/binutils/man"
Make sure file mode access permissions are correct:
# cd /opt/
# chmod -R o-w gcc
# chmod -R o-w binutils
Logout and then login again to make the above change
take effect.
Now we have the programs in the PATH and programs
like "sed", "ar", "as" etc. will be found in /opt/...
before in standard HP-UX location. So unless the
standard HP-UX is explicitly specified the Gnu
program will be used.
# whence sed
/opt/sed/bin/sed
Now it is possible to start use the Gnu C compiler.
To be able to use Gnu C++ we need to install C++ libraries
though.
C++ libraries
To be able to compile C++ programs you must have the "libg++".
Download the Statically Linked Binary.
# mv libg++-2.7.2-sa-9.05.upd libg++-2.7.2-sa-9.05.upd.gz
# gunzip *.gz
List a table of contents:
# /usr/sbin/update -S800 -c -s /install/x/gnu/libg++-2.7.2-sa-9.05.upd
# /usr/sbin/update -S800 -s /install/x/gnu/libg++-2.7.2-sa-9.05.upd PD_libg++
Some WARNING might appear, nothing to worry about.
Files should now be in:
/opt/hppd/lib/gcc
/opt/hppd/lib/hppa1.1-hp-hpux9.05/
/opt/hppd/man/man1/configure.1
/opt/hppd/man/man1/gperf.1
/var/adm/rupdate/system/PD_libg++/customize
/var/adm/rupdate/system/PD_libg++/decustomize
/var/adm/rupdate/system/PD_libg++/CDFinfo
/var/adm/rupdate/system/PD_libg++/index
# tail /var/tmp/update.log
* Source: /install/x/gnu/libg++-2.7.2-sa-9.05.upd
* Media type: Series 800
* Media format: A.B8.05
* Destination: /
* Filesets: 1
* Files: 353
* Kbytes: 3037
* Filesets selected:
* PD_libg++ A.B7.00
* Beginning to load fileset "PD_libg++" (1 of 1).
* Successfully loaded fileset "PD_libg++".
* Beginning customize script for fileset "PD_libg++" (1 of 1) using the
command: /var/adm/rupdate/system/PD_libg++/customize HP-PA
* Customize script for fileset "PD_libg++" succeeded.
Gnu C requires that libraries are installed in the same directory as
itself.
# cd /opt/gcc/lib
# ln -s /opt/hppd/lib/gcc/g++-include g++-include
# ln -s /opt/hppd/lib/gcc/libg++.a libg++.a
# ln -s /opt/hppd/lib/gcc/libg++.sl libg++.sl
# ln -s /opt/hppd/lib/gcc/libiberty.a libiberty.a
# ln -s /opt/hppd/lib/gcc/libstdc++.a libstdc++.a
# ln -s /opt/hppd/lib/gcc/libstdc++.sl libstdc++.sl
# ln -s /opt/hppd/lib/hppa1.1-hp-hpux9.05 hppa1.1-hp-hpux9.05
Test
# cd /tmp
# vi 1.cpp
------------------------------------
#include
main() {
cout << "Hello world" << "\n";
}
------------------------------------
# c++ 1.cpp
NOTE A C++ program must be compiled with "c++"
and not "gcc".
# ./a.out
Hello world