I nearly broke my head trying to compile PHP 5.3.6 on my Mac with GD and OpenSSL support enabled. For reference purposes, here is what my configuration looks like and what errors I were running into, while trying to make.
./configure \
--prefix=/opt/php \
--enable-fpm \
--with-mysql=mysqlnd \
--with-zlib-dir=~/nginx-build/zlib-1.2.5 \
--with-curl \
--enable-mbstring \
--disable-debug \
--with-gd \
--with-jpeg-dir=/opt/local \
--with-png-dir=/opt/local \
--with-config-file-path=/opt/php/etc/php.ini
make then chooses to fail with the following message.
Undefined symbols:
"_iconv", referenced from:
__php_iconv_strlen in iconv.o
_php_iconv_string in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_appendl in iconv.o
__php_iconv_appendl in iconv.o
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_zif_iconv_mime_encode in iconv.o
_zif_iconv_mime_encode in iconv.o
_zif_iconv_mime_encode in iconv.o
_zif_iconv_mime_encode in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_stream_filter_append_bucket in iconv.o
_php_iconv_stream_filter_append_bucket in iconv.o
(maybe you meant: _iconv_functions, _zif_iconv_mime_decode , _zif_iconv_substr , _zif_iconv_strlen ,
zif_iconv_strpos , _zif_ob_iconv_handler , _iconv_module_entry , _iconv_globals , _zif_iconv_mime_encode ,
_zif_iconv_get_encoding , _php_iconv_string , _zif_iconv_mime_decode_headers , cstring=ob_iconv_handler ,
_php_if_iconv , _zif_iconv_set_encoding , _zif_iconv_strrpos )
ld: symbol(s) not found
collect2: ld returned 1 exit status
The fix
The fix requires patching ext/iconv/iconv.c from the PHP source directory. Open ext/iconv/iconv.c in a text editor and make the following changes.
-
At line
54, delete the following three lines:#ifdef HAVE_LIBICONV #undef iconv #endif
-
At line
185, delete the following three lines:#if defined(HAVE_LIBICONV) && defined(ICONV_ALIASED_LIBICONV) #define iconv libiconv #endif
That should fix it. Go back and run make again and it should compile PHP successfully this time.
Here is the patch if you like:
--- iconv.c.original 2011-06-22 12:37:14.000000000 +0530 +++ iconv.c 2011-06-22 12:09:59.000000000 +0530 @@ -51,10 +51,6 @@ #include#endif -#ifdef HAVE_LIBICONV -#undef iconv -#endif - #include "ext/standard/php_smart_str.h" #include "ext/standard/base64.h" #include "ext/standard/quot_print.h" @@ -182,10 +178,6 @@ } /* }}} */ -#if defined(HAVE_LIBICONV) && defined(ICONV_ALIASED_LIBICONV) -#define iconv libiconv -#endif - /* {{{ typedef enum php_iconv_enc_scheme_t */ typedef enum _php_iconv_enc_scheme_t { PHP_ICONV_ENC_SCHEME_BASE64,