I'm trying to compile PHP and I kept getting this error during make:

Undefined symbols for architecture x86_64:
  "_iconv_open", referenced from:
      __php_iconv_mime_decode in iconv.o
      __php_iconv_strlen in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strpos in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _php_iconv_stream_filter_factory_create in iconv.o
      ...
  "_iconv_close", referenced from:
      __php_iconv_mime_decode in iconv.o
      __php_iconv_strlen in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strpos in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _php_iconv_stream_filter_dtor in iconv.o
      ...
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

The ./configure command of PHP has the iconv folder pointing to /opt/local, so the macport iconv library is used (which is installed using the the +universal flag). Doing file I get:

/opt/local/lib/libiconv.dylib: Mach-O universal binary with 2 architectures
/opt/local/lib/libiconv.dylib (for architecture i386):  Mach-O dynamically linked shared library i386
/opt/local/lib/libiconv.dylib (for architecture x86_64):    Mach-O 64-bit dynamically linked shared library x86_64

I tried then install the iconv library manually, forcing only the 64-bit architecture (I installed it in /usr/local) and it works. The output of file is:

/usr/local/lib/libiconv.dylib: Mach-O 64-bit dynamically linked shared library x86_64

Why is this happening? I manage to build and make PHP work with the manual installation, but I don't understand.

link|improve this question
feedback

migrated from serverfault.com Feb 26 at 15:42

This question came from our site for system administrators and desktop support professionals.

1 Answer

up vote 1 down vote accepted

The MacPorts iconv library renames the symbols to _libiconv_open and _libiconv_close. That's why PHP couldn't find them, not because of the forced 64-bit. Run nm /opt/local/lib/libiconv.dylib vs nm /usr/lib/libiconv.dylib (in 10.7.3).

link|improve this answer
Oh, now I understand. Thank you! – Entropy Feb 26 at 19:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.