-1

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?

Jason
  • 131
  • 1
  • 5
  • Actually libiconv should be 64 bit if you are using the system one. You can check with `file /usr/lib/libiconv.dylib` – dog Apr 08 '11 at 22:07
  • Thanks - the output is: `/usr/lib/libiconv.dylib: Mach-O universal binary with 3 architectures /usr/lib/libiconv.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 /usr/lib/libiconv.dylib (for architecture i386): Mach-O dynamically linked shared library i386 /usr/lib/libiconv.dylib (for architecture ppc7400): Mach-O dynamically linked shared library ppc` – Jason Apr 08 '11 at 22:28
  • This looks like I actually do have 64-bit iconv – Jason Apr 08 '11 at 22:29
  • However, I'm still getting this error... – Jason Apr 08 '11 at 22:38
  • looks like your library is compiled as a fat binary (i386 and x86_64) there is a way you can tell it to be only - look at com.apple.versioner and if possible configure it only for the arch you need. – silviud Apr 09 '11 at 00:36

1 Answers1

2

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).

Jonathan
  • 21
  • 2