Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

migrated from serverfault.com Feb 26 '12 at 15:42

This question came from our site for professional system and network administrators.

2 Answers 2

up vote 3 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).

share|improve this answer
    
Oh, now I understand. Thank you! –  Entropid Feb 26 '12 at 19:04
    
Thanks, I was able to get it working by pointing PHP to the non-macports version using --with-iconv-dir=/usr/lib –  simianarmy Jun 27 '12 at 17:19

In my case --with-iconv-dir=/usr/lib was not enough, I think this option don't work. So I manually renamed /opt/local/lib/libiconv.dylib to /opt/local/lib/libiconv.dylib.bak and after building renamed back.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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