php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43189 Fails to link iconv
Submitted: 2007-11-04 23:33 UTC Modified: 2009-06-01 09:20 UTC
Votes:39
Avg. Score:4.3 ± 0.8
Reproduced:37 of 37 (100.0%)
Same Version:12 (32.4%)
Same OS:37 (100.0%)
From: meh at mailinator dot com Assigned:
Status: Not a bug Package: ICONV related
PHP Version: 5.*, 6CVS (2009-06-01) OS: Mac OS X 10.5
Private report: No CVE-ID: None
 [2007-11-04 23:33 UTC] meh at mailinator dot com
Description:
------------
ld: warning, duplicate dylib /sw/lib/libssl.0.9.7.dylib
ld: warning, duplicate dylib /sw/lib/libcrypto.0.9.7.dylib
Undefined symbols:
  "_iconv_close", referenced from:
      _php_iconv_string in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      _php_iconv_stream_filter_dtor in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
  "_iconv_open", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _php_iconv_stream_filter_factory_create in iconv.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1


Reproduce code:
---------------
./configure --with-apxs2 --with-xsl --with-mysql=/sw --with-pdo --with-pdo-mysql=/sw --with-zlib --without-pear --with-iconv=/sw

I've tried --with-iconv and --with-iconv=/usr as well. Configure succeedes with any of these, but linker fails every time.

I have Fink installed:
/sw/lib/libiconv.2.4.0.dylib
/sw/lib/libiconv.2.dylib
/sw/lib/libiconv.dylib
/sw/lib/libiconv.la


Expected result:
----------------
Either configure should fail or linker should succeed.

Actual result:
--------------
Missing symbols...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-11 18:53 UTC] jani@php.net
How many iconv.h files do you have in your system? (search for *iconv*.h :)

 [2007-11-18 21:56 UTC] scott at mydogateit dot com
This is an issue with Leopards iconv.h file (/usr/include/iconv.h).

Try this...

$ sudo mv /usr/include/iconv.h /usr/include/iconv.h.leo_orig
$ sudo ln -s /sw/include/iconv.h /usr/include/iconv.h

and try make again. (I did this using iconv from MacPorts, but I assume 
the find dist will work just as well).
 [2007-11-22 22:06 UTC] msf at bitplan dot com
I have the same problem, even with a self compiled libiconv it does not 
work.
 [2007-12-14 15:45 UTC] aaa at mailinator dot com
@jani:
there are one per OS X sdk, one in /usr and one in /sw.

Linking suggested by scott solves the problem on me.
 [2007-12-18 08:45 UTC] leon at messiah dot co dot nz
Scott's method may work, but I'm loath to replace system provided header files.  Seems a bit hacky to me...

Wouldn't a more elegant solution be to configure your build to use the fink versions of the headers and library?

Something like:

--with-iconv-dir=/sw

I'm using MacPorts so have been trying to do the same thing but using /opt/local, so far without success.  However, I'm probably doing something wrong with the configure script (we're not the best of friends).
 [2008-01-20 19:59 UTC] mariano at petersonpages dot com
This configure option worked for me:

--with-iconv=shared,/opt/local

(Mac OS 10.5.1, PHP 5.2.5, iconv installed in /opt/local using macports)
 [2008-02-03 09:25 UTC] mjs at beebo dot org
Replacing /usr/include/iconv.h with the one from MacPorts and worked for 
me.  (I did need to re-configure and re-compile the whole thing though--
just re-running configure didn't work.)

For what it's worth, the --with-iconv=shared,/opt/local idea *didn't* 
work for me--php configured and built okay, but the iconv module didn't 
actually become available.  (php -m doesn't show it.)
 [2008-02-12 00:03 UTC] mjs at beebo dot org
This appears to be fixed in 10.5.2: the 10.5.2 /usr/include/iconv.h is 
different to the 10.5.1 version, and it compiles successfully as well.
 [2008-05-25 03:30 UTC] joe at joeruwe dot com
this happened for me in 10.5.2 with php 5.2.6.

i had to compile everything with --without-iconv then reconfigure and 
remake with the --with-iconv flag..
 [2008-10-15 09:19 UTC] safdf at mailinator dot com
I still have problem with this on 10.5.4. Could you please add a check or workaround for this in configure script?
 [2008-12-23 13:07 UTC] aalamaki at gmail dot com
Seems to be the same issue on PHP 5.2.8 and 10.5.6, I've tried doing the mac port with the --with-iconv=shared,/opt/local and it compiled but the iconv didn't come available.

I also tried copying over the iconv.h from the macports to the /usr/include but getting the errors mentioned in the first post, it will not compile with that.

Anyone have experience with this issue on 10.5.6 ?
 [2008-12-27 15:46 UTC] wickedguitar6 at yahoo dot com
Same problem on 10.5.6
I had to compile twice:

First time: ./configure --with-apxs2
            make
               ----> just to get libphp5.so

Second time: ./configure --with-iconv=/opt/local etc.etc.
             make
             make install
               ----> compiles normally as long as we do not require the apache2 module ("--with-apxs2") to be built.

Seems that the "--with-apxs2" directive confuses the linker and it doesn't know which libiconv to use (i.e. the MacPorts one, or the native MacOSX one).
 [2009-02-22 12:26 UTC] neilmsn at mac dot com
Odd I used the suggested --with-iconv=shared,/opt/local in the configure 
and it's worked now BUT it's 5.2.8 installed.

I must have somehow mixed my directories up, so I don't know if PHP 5.3 
fixed this error now.
 [2009-03-24 01:51 UTC] scottmac@php.net
Could you do

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

And see if that causes an error? If not then can you slowly add in each of your additional functions to see which one causes the error. We need the simplest configure string possible.

Also can you upload your config.log from the failed build somewhere.
 [2009-03-26 23:12 UTC] chanleo1985 at gmail dot com
I used a self compiled libiconv downloaded from GNU.
setenv DYLD_LIBRARY_PATH to be my self compiled libiconv/lib

compiling it as static module does not work. I got the same linker error as above. Configure passed but Make failed

But compiling it as dynamic module , using --with-iconv=shared, worked for me. Configure passed and Make passed

Bare in mind that even if configure passed and make passed, iconv still won't show up when you do php -m to list all the modules. You need to set php.ini to enable it. Need to add the following lines

extension_dir = /location/of/iconv.so
extension=iconv.so
 [2009-03-26 23:21 UTC] scottmac@php.net
I need the config.log for the static build to try and work out whats happening.
 [2009-03-27 06:10 UTC] senz at senz dot su
To scottmac@php.net:
here's my config.log from compilation with error.
iconv compiled by macports. --with-iconv-dir=shared,/opt/local and static both failed.
http://rapidshare.com/files/214033749/config.log.html
i also send a copy on your email.
 [2009-03-27 06:26 UTC] senz at senz dot su
Changing --with-iconv-dir to --with-iconv=shared,/opt/local
solve it on my system.

/opt/local = macports with iconv
 [2009-04-24 17:38 UTC] richard dot sentino at mindginative dot com
This configure option worked for me:

--with-iconv=/opt/local

(Mac OS 10.5.6, PHP 5.2.9, iconv installed in /opt/local using macports)

but it doesn't work with this configure option :

--with-iconv=shared,/opt/local

the configure passed and make passed but iconv won't show up when I do php -m
 [2009-04-30 13:03 UTC] scottmac@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2009-05-24 15:54 UTC] meh at mailinator dot com
It still fails for me in php5.3-200905241430.

This workaround still necessary:
sudo mv /usr/include/iconv.h /usr/include/iconv.h.leo_orig
sudo ln -s /sw/include/iconv.h /usr/include/iconv.h
rm ext/iconv/*.*o
make
 [2009-05-28 16:42 UTC] philip@php.net
For me, the following solution worked:

http://blog.yimingliu.com/2009/02/24/missing-library-symbols-while-
compiling-php-528/

Which involves moving around $(MH_BUNDLE_FLAGS). Looks like a different 
yet related bug however, but ....
 [2009-06-01 09:09 UTC] jani@php.net
Scott, apparently your fix didn't help?
 [2009-06-01 09:13 UTC] jani@php.net
Just an idea: How about you remove the extra installations of the 
libraries and only use ONE at the time? Or tune your library paths to be 
correct..
 [2009-06-01 09:14 UTC] jani@php.net
And please don't reopen old bugs like this, now there were 2 reports for 
same issue..
 [2009-06-01 09:20 UTC] jani@php.net
See bug #48195
 [2012-11-28 03:21 UTC] fuckrightoff at mailinator dot com
For anyone looking to troubleshoot this problem on Mac OS X on 5.3.* or 5.4.*, a 
step-by-step solution:

You need to test to make sure you are linking against a version of libiconv that 
contains symbols that begin with _libiconv_, e.g. "_libiconv_open".

To test this, find all files named libiconv.a, libiconv.so or libiconv.dylib and 
for each one type:

nm <filename> | grep _libiconv

If you see functions matching that signature link against that version of the 
library.  You may need to compile a new version of libiconv.  If the version you 
find ends in .a (i.e. libiconv.a) then it's a static library and you need to 
manually link it into PHP.  In order to do that, run ./configure as normal, then 
before typing "make", edit the Makefile and add the line:

EXTRA_CFLAGS = path/to/libiconv.a

Make sure you include that line early in the file.  I chose to place it right 
below "CONFIGURE_OPTIONS"

Also, be sure to check that your Makefile does not already include an 
EXTRA_CFLAGS variable, or you may clobber something essential.  If that's the 
case, just append the path/to/libiconv.a to the end of the EXTRA_CFLAGS option.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 01 23:01:29 2024 UTC