php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48195 iconv link failure
Submitted: 2009-05-08 19:50 UTC Modified: 2010-03-10 23:29 UTC
Votes:12
Avg. Score:5.0 ± 0.0
Reproduced:12 of 12 (100.0%)
Same Version:4 (33.3%)
Same OS:12 (100.0%)
From: rickdunn at chez dot com Assigned: scottmac
Status: Closed Package: Compile Failure
PHP Version: 5.3.1 OS: MacOSX 10.6.2
Private report: No CVE-ID:
 [2009-05-08 19:50 UTC] rickdunn at chez dot com
Description:
------------
Bug #43189 has returned in 5.3 RC2.  Make fails with 'undefined symbols'
related to iconv.

Reproduce code:
---------------
CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer -arch x86_64 -m64" CXX=gcc CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -arch x86_64 -m64" ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/sbin/apxs --with-config-file-scan-dir=/usr/local/php5/php.d --with-ldap=/usr --with-bz2=/usr --with-kerberos=/usr --enable-cli --with-zlib-dir=/usr --enable-exif --enable-soap --enable-ftp --enable-mbstring --enable-mbregex --enable-sockets --with-iodbc=/usr --with-curl=shared,/usr --sysconfdir=/private/etc --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-xmlrpc --with-xsl=/usr  --with-gd --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6 --enable-gd-native-ttf --with-mcrypt=shared --enable-calendar --enable-bcmath

Expected result:
----------------
Successful installation.

Actual result:
--------------
Make fails.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-09 11:53 UTC] rickdunn at chez dot com
Up until the release of 5.3.0 RC2, I could successfully compile PHP on 
OS X 10.5.6.  Now, 'Make' always fails with this message:

Undefined symbols:
  "_libiconv", referenced from:
      __php_iconv_appendl in iconv.o
      __php_iconv_appendl in iconv.o
      _php_iconv_string in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_strpos 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
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1
 [2009-05-09 21:00 UTC] jani@php.net
Drop all this first:

CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer -arch x86_64 -m64" CXX=gcc
CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors
-fno-exceptions -fno-rtti -arch x86_64 -m64" 

 [2009-05-09 22:45 UTC] scottmac@php.net
The bug you linked to was fixed for 5.3.0RC2, its possible that this is what caused your issues.

Did you checkout to a fresh directory?

If not you might need to run ./buildconf and ./configure again.
 [2009-05-10 12:03 UTC] rickdunn at chez dot com
No luck.  

I tried running ./buildconf before ./configure and the same error 
occurs.

I tried stripping out all of the compiler flags except for " -arch 
x86_64 -m64" and still get the same error.

Again, this problem showed up with 5.3.0RC2.  I did not have any 
problems with 5.3.0RC1.
 [2009-05-10 18:38 UTC] scottmac@php.net
Can you try with

./configure --disable-all --with-xmlrpc --enable-libxml


The above configures file for me on 10.5.6.
 [2009-05-11 20:57 UTC] rickdunn at chez dot com
The problem seems to be that the 5.3 RC2 build has a problem with the "-
arch x86_64" compiler flag.  If I run a stripped-down configure...

./configure --disable-all --with-iconv --with-apxs2

...I don't get any errors, but I'll end up with a 32-bit PHP module and 
I'm running 64-bit Apache.

Compiling for 64-bit was not a problem with 5.2.x or 5.3 RC1.
 [2009-05-12 02:19 UTC] scottmac@php.net
Can you apply http://whisky.macvicar.net/patches/apache2handler.patch.txt

Run ./buildconf and then configure again.

This should fix the issue you're having.
 [2009-05-12 15:55 UTC] rickdunn at chez dot com
Unfortunately, no luck.  I applied the patch, ran ./buildconf and then 
ran the following:

CFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" 
CCFLAGS="-arch x86_64" ./configure --disable-all --with-iconv --with-
apxs2

'Make' still fails with the same error.

For what it's worth, I compiled 5.2.9 successfully today, so nothing 
seems to have changed on my computer that would cause this.
 [2009-05-12 16:10 UTC] scottmac@php.net
Can you show me the last command it tried to run from linking?

Usually you have -L/usr/lib and -L/opt/local/lib or similar.
 [2009-05-12 17:38 UTC] rickdunn at chez dot com
Here's the last few lines and the error:

Zend/zend_object_handlers.o Zend/zend_objects_API.o 
Zend/zend_default_classes.o Zend/zend_execute.o 
sapi/apache2handler/mod_php5.o sapi/apache2handler/sapi_apache2.o 
sapi/apache2handler/apache_config.o 
sapi/apache2handler/php_functions.o main/internal_functions.o  -liconv 
-liconv -lm  -o libs/libphp5.bundle && cp libs/libphp5.bundle 
libs/libphp5.so
Undefined symbols:
  "_libiconv", referenced from:
      __php_iconv_appendl in iconv.o
      __php_iconv_appendl in iconv.o
      _php_iconv_string in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_strpos 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
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1
 [2009-05-29 16:08 UTC] philip@php.net
See Bug #43189 for a [temporary] workaround, which involves editing 
Makefile.
 [2009-06-01 09:16 UTC] jani@php.net
I think the reason is that people have several versions of iconv 
installed in their system. Just remove the extra / wrong / whatever and 
it will work fine..
 [2009-06-01 09:24 UTC] jani@php.net
Please provide the generated Makefile's for PHP 5.2.9 (that works) and 
PHP 5.3 (that does not work) using same configure options for both. And 
as few options as possible, thankyouverymuch. :)
 [2009-06-06 16:42 UTC] rickdunn at chez dot com
I get the same error now when I try to compile 5.2.9.  The solution in 
Bug #43189 did not work for me.
 [2009-12-15 22:32 UTC] rickdunn at chez dot com
Apple has a patch for the PHP source iconv.c file that fixes this 
problem:

http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-
53/patches/iconv.patch
 [2009-12-16 08:31 UTC] jani@php.net
That's just fixing a symptom, not the bug.
 [2009-12-22 12:22 UTC] rickdunn at chez dot com
The snapshot make failed with the usual message. "Undefined symbols:
  "_libiconv", referenced from:", etc.
 [2009-12-22 14:37 UTC] jani@php.net
I deleted the irrelevant comments from this report, it was getting too noisy. Now, is it still so that compiling PHP 5.2.12 works and only 5.3 fails?

Please show the output of these commands after running configure (for the failed build :)

# grep ICONV main/php_config.h | grep define

and 

# cat php_have_bsd_iconv.h \
php_have_glibc_iconv.h \
php_have_ibm_iconv.h \
php_have_iconv.h \
php_have_libiconv.h \
php_iconv_supports_errno.h \
php_php_iconv_h_path.h \
php_php_iconv_impl.h

 [2009-12-22 15:10 UTC] rickdunn at chez dot com
I don't use 5.2.*, so this is just a 5.3.* issue for me.  Here's the 
output requested:

The grep results...

#define HAVE_ICONV 1
#define PHP_ICONV_IMPL "libiconv"
#define PHP_ICONV_IMPL "libiconv"
#define PHP_ICONV_IMPL "libiconv"
#define PHP_ICONV_IMPL "libiconv"
#define ICONV_SUPPORTS_ERRNO 1
#define ICONV_SUPPORTS_ERRNO 1
#define ICONV_SUPPORTS_ERRNO 1
#define PHP_ICONV_H_PATH </usr/include/iconv.h>
#define HAVE_ICONV 1

And the cat results...

#define HAVE_ICONV 1
#define HAVE_LIBICONV 1
#define ICONV_SUPPORTS_ERRNO 1
#define PHP_ICONV_H_PATH </usr/include/iconv.h>
#define PHP_ICONV_IMPL "libiconv"
 [2010-01-02 20:38 UTC] iongion at yahoo dot com
I think i found solution to this.
It is clearly the compiler or linker being upset.

I remove all traces of iconv from my computer (an osx) and of php (even the default one that snow leopard comes with)

Then i installed a fresh iconv + compile fresh php 5.3.1

Everything worked.

I had lots of libiconv builds in my /usr/local/lib

(remember, i first deleted all traces of iconv or php, headers, so, dylib, a)
 [2010-01-08 02:24 UTC] quanah at zimbra dot com
I'm hitting this problem on Snow Leopard (OSX 10.6) with PHP 5.2.12, since it was asked.  I have no desire to use a custom iconv build.
 [2010-03-10 22:23 UTC] jani@php.net
-Status: Open +Status: Feedback
 [2010-03-10 22:23 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2010-03-10 22:48 UTC] rickdunn at chez dot com
I just tested the latest snapshot and the problem seems to be fixed.  Thanks!
 [2010-03-10 22:50 UTC] rickdunn at chez dot com
FYI, I used http://snaps.php.net/php5.3-latest.tar.gz for the successful build.
 [2010-03-10 23:29 UTC] jani@php.net
-Status: Open +Status: Closed
 [2010-03-10 23:29 UTC] jani@php.net
Prolly fixed by the fix for bug #49267
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 07:02:02 2014 UTC