Steps to produce a libiconv.so php extension so you can use the iconv() function in PHP
#0.1 Do a find and replace for /usr/local/phpdave7 and switch it to your base installation path of php for example /usr/local/zendsvr | |
#0.2 Do a find and replace for /QOpenSys/litmis/ibmichroot/ and switch it to the directory where shr4.o or shr.o is. Run `find / -name shr4.o` if you need to locate this file. | |
#0.3 Do a find and replace for /usr/linux and switch it to the directory where your bin/iconv and lib/libiconv are located possibly /opt/freeware | |
#1.0 find your PHP Version | |
php -v | |
>PHP 5.6.7 (cli) (built: Apr 2 2015 15:32:22) | |
#2 get latest iconv php extension which is included in the php-src | |
git clone -b PHP-5.6.7 http://git.php.net/repository/php-src.git | |
#3 If you dont have libiconv.a, Get libiconv from perzl and then fix it | |
wget http://www.oss4aix.org/download/RPMS/libiconv/libiconv-1.14-3.aix5.1.ppc.rpm | |
rpm –ignoreos –ignorearch –nodeps –replacepkgs –oldpackage -hUv libiconv-1.14-3.aix5.1.ppc.rpm | |
#4 tonys code on fixing libiconv | |
ar -x /QOpenSys/usr/lib/libiconv.a | |
# Argh Matie, we be needin' to make a ugly baby to fool the IFS Kraken | |
cp /opt/freeware/lib/libiconv.a /opt/freeware/lib/libiconv-lady-in-waiting.a | |
#ar -rv /opt/freeware/lib/libiconv-lady-in-waiting.a shr4.o | |
ar -rv /opt/freeware/lib/libiconv-lady-in-waiting.a /QOpenSys/litmis/ibmichroot/shr4.o | |
#ar -rv /opt/freeware/lib/libiconv-lady-in-waiting.a shr.o | |
ar -rv /opt/freeware/lib/libiconv-lady-in-waiting.a /QOpenSys/litmis/ibmichroot/shr.o | |
rm /opt/freeware/lib/libiconv.a | |
cp /opt/freeware/lib/libiconv-lady-in-waiting.a /opt/freeware/lib/libiconv.a | |
#5 change directory to where php-src was downloaded and go to the iconv extension directory | |
cd php-src/ext/iconv | |
#6 make a copy of our current iconv.so extension (so you can revert back if needed) | |
cp /usr/local/zendsvr/lib/php_extensions/iconv.so /usr/local/zendsvr/lib/php_extensions/iconv.so-orig | |
#7 setup environment variables for configure and make | |
export IBM_DB_HOME=/usr | |
export PHP_HOME=/usr/local/phpdave7 | |
export PASE_TOOLS_HOME=/QOpenSys/usr | |
export AIX_TOOLS_HOME=/usr/local | |
export PATH=$PATH:$PHP_HOME/bin:$PASE_TOOLS_HOME/bin:$AIX_TOOLS_HOME/bin | |
export LIBPATH=$PHP_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 | |
#8 check the gcc version | |
gcc -v | |
Target: powerpc-ibm-aix6.1.0.0 … used in CCHOST above | |
#9 compile php extension by running (change –with-iconv to the base folder with iconv): | |
#phpize, configure, gmake, gmake test, and gmake install | |
phpize && ./configure –build=$CCHOST –host=$CCHOST –target=$CCHOST –cache-file=../config.cache –with-iconv=/usr/linux && gmake && gmake test && gmake install | |
#"gmake install"s it to /usr/local/phpdave7/lib/php/extensions/no-debug-non-zts-20160303/iconv.so | |
#10 -d will force temporary loading the extension (add extension=iconv.so to permenantly always load it) –ri display the configuration of an extension | |
php -dextension=iconv.so –ri iconv | |
#11 check what php extension modules are loaded | |
php -m | |
#12 edit php.ini to tell PHP to load iconv php extension by adding extension=iconv.so | |
echo "extension=iconv.so" >> /usr/local/lib/php.ini | |
#::NOTES:: | |
#view compiled extension | |
ls /usr/local/phpdave7/lib/php/extensions/no-debug-zts-20160303 | |
#if you have two libiconv.a you'll have to fix that or the libpath might cause issues | |
#common symbolic links | |
#ln -sf /QOpenSys/opt/freeware/bin /usr/local/bin | |
#ln -sf /QOpenSys/opt/freeware/lib /usr/local/lib | |
#Rather not create hard links try and figure alternative | |
export PATH=/opt/freeware/bin:$PATH | |
#Had to remove LIBPATH w/ $PASE_TOOLS_HOME because it was using the wrong libiconv | |
#export LIBPATH=/usr/local/phpdave7/lib:/usr/local/lib | |
#php -v | |
#Could not load program php: | |
# Dependent module /QOpenSys/usr/lib/libiconv.a(libiconv.so.2) could not be loaded. | |
# Member libiconv.so.2 is not found in archive | |
##had to create symlink to glink.o which was missing when i started compiling | |
#ln -s /QOpenSys/usr/lib/glink.o /usr/lib/glink.o | |
#note depending on how PHP is configured on your system their will be either be a debug build or Zend Thread Safety (ZTS) builds of the extension | |
#$PREFIX/lib/php/extensions/no-debug-non-zts-API_NO for release builds without ZTS | |
#$PREFIX/lib/php/extensions/debug-non-zts-API_NO for debug builds without ZTS | |
#$PREFIX/lib/php/extensions/no-debug-zts-API_NO for release builds with ZTS | |
#$PREFIX/lib/php/extensions/debug-zts-API_NO for debug builds with ZTS | |
[usrcis42@SPACES]~% ls -l /usr/linux | |
total 192 | |
drwx—— 2 usrcis42 0 57344 Jun 6 22:06 bin | |
drwx—— 2 usrcis42 0 8192 Apr 15 12:57 include | |
drwx—— 2 usrcis42 0 24576 Apr 15 12:58 lib | |
drwx—— 2 usrcis42 0 8192 Apr 15 12:58 lib64 | |
[usrcis42@SPACES]~% ls -l /usr/linux/bin/iconv | |
lrwxrwxrwx 1 usrcis42 0 62 Apr 15 12:57 /usr/linux/bin/iconv – | |
> ../../../opt/freeware/bin/iconv | |
[usrcis42@SPACES]~% ls -l /usr/linux/lib/libiconv.a | |
lrwxrwxrwx 1 usrcis42 0 72 Apr 15 12:57 /usr/linux/lib/libicon | |
v.a –> ../../../opt/freeware/lib/libiconv.a |