Tag Archives: GD

OSX Server 10.5.8 で PHP+GD

アップデートしたときにPHPのバージョンも変更(5.2.10)されていたことに気づかず、GDが入っていないPHPに置き換えられていたので再度PHPをGD付きでコンパイルしたのでメモ。

各ライブラリの今回利用したバージョンは以下の通り。

  • libpng 1.2.40
  • libjpeg jpeg-7
  • gd 2.0.35
  • php 5.2.10

PHPをMacでコンパイルするとlibiconv関係でリンク時にエラーが出る問題があるそうなのでext/iconv/iconv.cの196行目あたりを以下のように書き換えてからコンパイルに移ります。(参照:PHP Bugs: #49267: Linking fails for iconv: “Undefined symbols: _libiconv”)
Before

#ifdef HAVE_LIBICONV
#define iconv libiconv
#endif

After

#ifdef HAVE_LIBICONV
#define iconv iconv
#endif

実行した手順だけを載せます。

<code>
$ cd ~/Downloads/src/libpng-1.2.40
$ CFLAGS="-arch x86_64" CCFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" ./configure
$ make
$ sudo make install

$ cd ~/Downloads/src/gd-2.0.35
$ CFLAGS="-arch x86_64" ./configure
$ cp libtool ../jpeg-7/
$ cd ../jpeg-7/
$ MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure --enable-shared
$ make
$ sudo make install

$ cd ~/Downloads/src/gd-2.0.35
$ MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure --with-zlib-dir=/usr --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6
$ make
$ sudo make install

$ cd ~/Downloads/src/php-5.2.10
$ MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --with-apxs2=/usr/sbin/apxs --with-ldap=/usr --with-kerberos=/usr --enable-cli --with-zlib-dir=/usr --enable-trans-sid --with-xml --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-dbx --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc --sysconfdir=/private/etc --with-mysql-sock=/var/mysql --with-mysqli=/usr/bin/mysql_config --with-mysql=/usr --with-openssl --with-xmlrpc --with-xsl=/usr --without-pear --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/X11R6 --with-gd=/usr/local
$ make
$ make test
$ sudo make install
</code>