The problem with the libiconv supplied by Apple is that its symbols do not start with _lib
. So instead of _libiconv_open
you get _iconv_open
. You can check it like this:
$ nm /usr/lib/libiconv.dylib | grep iconv_open
0000000000001c59 T _iconv_open
If you are using macports, you should get this:
$ nm /opt/local/lib/libiconv.dylib | grep iconv_open
0000000000001350 T _libiconv_open
00000000000027a0 T _libiconv_open_into
To fix this problem, you have to install the appropriate libiconv:
$ sudo port install libiconv @1.14_0+universal
Then whenever you are linking to libiconv, replace /usr/lib/libiconv.dylib
with /opt/local/lib/libiconv.dylib
. (Hint: Finder supports search within files if you can't fix configure script or cmake.)
Another thing worth noting is that you must make sure libiconv is targeted at the correct architecture, check it like this:
$ file /usr/lib/libiconv.2.dylib
/usr/lib/libiconv.2.dylib: Mach-O universal binary with 2 architectures: [i386: Mach-O i386 dynamically linked shared library] [x86_64]