Installing PHP with iconv on Mac OSX 10.6 gives error: “Undefined symbols for architecture x86_64” [closed]

I am setting up PHP on my local web server with iconv, which should be there by default, but I am getting the following error:

Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      __php_iconv_strlen in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_appendl in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _php_iconv_stream_filter_append_bucket in iconv.o
      ...
     (maybe you meant: _zif_iconv_strlen, _zif_iconv_strpos , _zif_iconv_mime_decode , _php_iconv_string , _zif_iconv_set_encoding , _zif_iconv_get_encoding , _zif_iconv_mime_decode_headers , _iconv_functions , _zif_iconv_mime_encode , _zif_iconv_strrpos , _iconv_module_entry , _iconv_globals , _zif_iconv_substr , _php_if_iconv , _zif_ob_iconv_handler )
ld: symbol(s) not found for architecture x86_64

Now, presumably this means that my iconv is not 64 bit. I tried to download libiconv and manually reinstall it with 64 bit, as such:

CFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64' CCFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64' CXXFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64' ./configure

But I get the following error:

configure: error: in `/Users/jason/Downloads/libiconv-1.13.1':
configure: error: C compiler cannot create executables
See `config.log' for more details.

In my config.lob file, it says at the bottom:

configure: exit 77

Any suggestions?

Answer

I’ve had exactly the same problem on OS X 10.7, i.e. couldn’t compile PHP due to the libiconv x86_64 errors, but have solved it as follows:

Build an x86_64-only version of libiconv:

CFLAGS='-arch x86_64' CCFLAGS='-arch x86_64' CXXFLAGS='-arch x86_64' ./configure
make
sudo make install

This will put the compiled files in /usr/local/lib

Then run ./configure in the PHP source directory, then ‘make’

When you get the error with iconv, copy the last gcc command (the one that failed), change the start to:

gcc -bundle -bundle_loader /usr/sbin/httpd -L/usr/local/lib

so it’s pointing to the 64-bit-only version. Then paste the new command and run ‘make’ again and it works (at least did for me).

Attribution
Source : Link , Question Author : Jason , Answer Author : Jonathan

Leave a Comment