Tuesday, April 10, 2012

Compile PHP with GD for iPhone OS 4.1

The Goal:

have a working version of PHP with the GD library working on an iPod Touch 4th Gen.

The Status:

PHP is working on the iPod (lighttpd + PHP 5.2.8 + sqlite3) without GD.

When trying to compile PHP on the iPod I get this error: http://pastebin.com/kUmgq70G

The Proposed Solution:

Can anyone point me in the direction of how to compile PHP with GD and then package it up nicely as a .deb file for everyone else to use?

The best situation I believe is to compile the latest version of PHP with the GD library included and enabled. Second best would be to settle for compiling GD as a module and then installing that into the currently working PHP that is available from Cydia. However to compile GD you would have to do this with the SAME source that was used to create the php_5.2.8-3_iphoneos-arm.deb available from Cydia - I think it would be easier and safer for everyone in the future to just compile a fresh PHP with GD already enabled and then pack it up as a .deb

Here is what I have from phpinfo of the currently installed version of PHP: System:

Darwin iPod-Touch 10.3.1 Darwin Kernel Version 10.3.1: Wed Aug 4 22:35:51 PDT 2010; root:xnu-1504.55.33~10/RELEASE_ARM_S5L8930X iPod4,1

Build Date:

Jan 25 2009 02:55:42

Configure Command:

'./configure' '--build=x86_64-unknown-linux-gnu' '--host=arm-apple-darwin9' '--enable-static=no' '--enable-shared=yes' '--prefix=/usr' '--localstatedir=/var/cache/php' '--with-iconv=/usr/arm-apple-darwin9/usr' '--with-curl=/home/dat/apl/tel/dest/iphoneos-arm/curl/usr' '--enable-fastcgi'

Here is the package information from Cydia's repo:

Package: php
Version: 5.2.8-3
Architecture: iphoneos-arm
Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
Installed-Size: 14492
Depends: curl, libxml2
Filename: debs/php_5.2.8-3_iphoneos-arm.deb
Size: 4626280
MD5sum: dbb30ea608945a5d45de02df74df71b0
Section: Development
Priority: optional
Description: overly popular HTML templating language
Name: PHP: Hypertext Preprocessor
Tag: purpose::console, role::developer

P.S. I am not the only person working on this, as during my searching I found several other posts with people who need this too. Once I have this completed I will host the file somewhere so that everyone can enjoy.

Source: Tips4all


  1. From your output it seems that php compiles fine, but fails to link to the resolv library.

    If you need a workaround for getting PHP 5.2, you will need to manually add -lresolv to the linker flags.

    This seems to be a bug in PHP 5.2 compiled with apple's tools (http://bugs.php.net/49332) which is fixed in PHP 5.3, so you might try 5.3 one unless you really need 5.2 for some reason.

  2. I didn't tried myself, but the Saurik repository should help :


    And especially this one might interest you :


    Cydia packages comes from that, thanks Saurik for his huge work of course!

  3. This never happened. Saurik never responded to me either. So I dropped this project.

  4. Just wanted to let everyone know that the PHP GD module is now available through Cydia! I don't think you have to add any sources for it, but if it's not available in the default repos, check out the info here!