libiconv and MacOS

Javier Moreno picture Javier Moreno · Sep 27, 2012 · Viewed 13.4k times · Source

I am trying to compile GCC 4.5.1 in Mac OS X Lion.

I have a problem with libiconv. First it complained about undefined symbols for architecture x86_64, which were: _iconv, _iconv_open and _iconv_close. I found out that MacPorts version of libiconv rename those to: _libiconv, _libiconv_open and _libiconv_close. So I linked to the Mac OS native libiconv in /usr/lib instead of the MacPorts library in /opt/local/lib.

Undefined symbols for architecture x86_64:
"_iconv", referenced from:
  _convert_using_iconv in libcpp.a(charset.o)
  __nl_find_msg in libintl.a(dcigettext.o)
 (maybe you meant: __cpp_destroy_iconv, _cpp_init_iconv )
"_iconv_close", referenced from:
  __cpp_destroy_iconv in libcpp.a(charset.o)
  __cpp_convert_input in libcpp.a(charset.o)
  __nl_free_domain_conv in libintl.a(loadmsgcat.o)
"_iconv_open", referenced from:
  _init_iconv_desc in libcpp.a(charset.o)
  __nl_init_domain_conv in libintl.a(loadmsgcat.o)

However, after doing that, I tried to rebuild it from the beginning (cleaning and everything), but then it complained at a different point about undefined symbols, but this time _libiconv, _libiconv_open and _libiconv_close.

Undefined symbols for architecture x86_64:
  "_libiconv", referenced from:
    _identifier_to_locale in libbackend.a(pretty-print.o)
  "_libiconv_close", referenced from:
    _identifier_to_locale in libbackend.a(pretty-print.o)
  "_libiconv_open", referenced from:
    _identifier_to_locale in libbackend.a(pretty-print.o)

Is there any idea about how I can deal with this? I have found some solutions uninstalling libiconv from MacPorts, but I don't want to do it, as I have many ports depending on it.

Answer

Erik Kaplun picture Erik Kaplun · Dec 7, 2015

I solved it by:

$ sudo port -f deactivate libiconv
$ ...build my project...
$ sudo port activate libiconv

There's probably a better way but I'm not using GCC directly, so this helps as a temporary workaround.