GCC

(click to open)

Quick Page Table of Contents

Scanning…

gcc

replaced

Most of these instructions are out of date with the times. The new LPP OPS has much better setup of GCC, including chroot development. See OpenSourceBeta - GCC and chroot.

gcc on IBM i

A quick script to help install gcc on IBM i. This information is offered “as is”.

Installing gcc

Thanks to Michael Perzlís fantastic site ( perzl.org), IBM i binaries of many OpenSource projects are available. Though, prior to installing gcc you need to prepare your system according to Open Source Binaries (you donít need to install any packages using wwwinstall.sh Ė this script points to the old IBM binaries).

Once youíve prepared your system according to the wikiís instructions, run wwwinstallgcc.sh (also copied to /QOpenSys/download) in a PASE shell (CALL QP2TERM) to install gcc and all its prereqs. Using --all as the sole argument will do the trick. To see the complete syntax, call this script without any arguments.

> wwwinstallgcc.sh 
wwwinstallgcc.sh [--package=<package>] [-m=<mode>|--mode=<mode>] [--replace]
 modes (action):
   --mode=complete - wget and install rpms (default)
   --mode=wget     - wget rpms only
     --replace     - When using mode 'complete' or 'wget' existing rpm files will be replaced
   --mode=install  - install rpms only
   --mode=erase    - uninstall/erase rpm packages (risky)
   --mode=destroy  - uninstall/erase all rpm packages matching general name (VERY risky)
   --mode=clean    - remove rpm files not product (after install, not recommended)
 modes (display):
   --mode=info     - display rpms for selected package
   --mode=content  - display rpm content for selected package (rpm -qlp)
   --mode=depend   - display rpm dependencies for selected package (rpm -qRp)
   --mode=query    - display rpm currently installed for selected package (rpm -qa)
 packages:
   --package=all (default)
   --package=gcc
   --package=gcc-c++
   --package=gcc-cpp
   --package=libgcc
   --package=libgomp
   --package=libstdc
   --package=mpfr
   --package=gmp
   --package=libmpc
 rpm (versions):
  gcc-4.6.2-1  gcc-c++-4.6.2-1  gcc-cpp-4.6.2-1 
  libgcc-4.6.2-1  libgomp-4.6.2-1  libstdc++-4.6.2-1 
  mpfr-3.1.2-1  gmp-5.0.5-1  libmpc-1.0.1-2 

Troubles some versions gcc (see Open Source Binaries this wiki)

bash-4.2$ gcc 
Could not load program gcc:
        Dependent module /opt/freeware/lib/libiconv.a(libiconv.so.2) could not be loaded.
Could not load module /opt/freeware/lib/libiconv.a(libiconv.so.2).
System error: No such file or directory
bash-4.2$ ls -l /opt/freeware/lib/libiconv.a
/opt/freeware/lib/libiconv.a not found
bash-4.2$ pwd
/QOpenSys/download
bash-4.2$ ./wwwperzl.sh aix61 wget libiconv-1.14-2
:
bash-4.2$ ./wwwperzl.sh aix61 rpm libiconv-1.14-2

don't forget paths ..

export PATH=/opt/freeware/bin:/usr/local/bin:$PATH
export LIBPATH=/opt/freeware/lib:/usr/local/lib:$LIBPATH

Test gcc

> e fred.c &
#include <stdio.h>
int main(int argc, char *argv[])
{
  printf("Hello Fred!\n");
}
> gcc -o fred fred.c 
> ./fred
Hello Fred!
>

gcc related packages (pecl compile example)

Not all binaries on Perzl will run on IBM i PASE, especially “latest / greatest” AIX (everyone instinctively wants latest), due to IBM i PASE lagging behind AIX technology releases, to wit, PASE is ALWAYS an older version, therefore as you can see below the 2008–10 vintage perzl binaries worked on my machine (V6R1), while “latest / greatest” may cause a core dump (aka m4 does not run … and … so on).

Follow instructions clean ... http://www.youngiprofessionals.com/wiki/index.php/PASE/GCC
> cd /QOpenSys
> ./wwwclean.sh

Follow instructions setup ... http://www.youngiprofessionals.com/wiki/index.php/PASE/OpenSourceBinaries
> cd /QOpenSys/download
> ./setup2.sh                 (see new setup2.sh on web page removes old /usr/bin/rpm, etc. )

Follow instructions gcc load ... http://www.youngiprofessionals.com/wiki/index.php/PASE/GCC
wwwinstllgcc.sh --package=all --mode=complete

Addtional files for pecl builds ...
wget ftp://www.oss4aix.org/download/RPMS/m4/m4-1.4.10-1.aix5.1.ppc.rpm
wget ftp://www.oss4aix.org/download/RPMS/libsigsegv/libsigsegv-2.10-1.aix5.1.ppc.rpm
wget ftp://www.oss4aix.org/download/RPMS/sed/sed-4.2.1-2.aix5.1.ppc.rpm
wget ftp://www.oss4aix.org/download/RPMS/autoconf/autoconf-2.63-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv m4-1.4.10-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv libsigsegv-2.10-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv sed-4.2.1-2.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv autoconf-2.63-1.aix5.1.ppc.rpm

also may need (see wwwperzl.sh aix53 rpm libiconv-1.14-2)
libiconv-1.14-2.aix5.1.ppc.rpm

cd /home/myuid/mypecl
export PHP_HOME=/usr/local/zendsvr
export PASE_TOOLS_HOME=/QOpenSys/usr
export AIX_TOOLS_HOME=/usr/local
export PERZL_TOOLS_HOME=/opt/freeware
export PATH=$PHP_HOME/bin:$PERZL_TOOLS_HOME/bin:$PASE_TOOLS_HOME/bin:$AIX_TOOLS_HOME/bin:$PATH
export LIBPATH=$PHP_HOME/lib:$PERZL_TOOLS_HOME/lib:$PASE_TOOLS_HOME/lib:$AIX_TOOLS_HOME/lib
export CC=gcc
export CFLAGS="-DPASE -I=.:$PHP_HOME/php/include"
export CCHOST=powerpc-ibm-aix6.1.0.0

phpize
./configure --build=$CCHOST --host=$CCHOST --target=$CCHOST --with-whatever=/path
make
make install
cp /usr/local/zendsvr/lib/php/20090626/*.so /usr/local/zendsvr/lib/php_extensions/.
Note: If you get 'Device busy' stop zendsrv web server then retry copy and restart

Author(s)

Tony “Ranger” Cairns - IBM i PHP / PASE