Sunday, February 1, 2009

Installing Sphinx on OS X Leopard

Sphinx can be a pain to install on OS X if you need the bleeding edge version. At the time MacPorts has only 0.9.8 (latest stable) in repository, and 0.9.9-rc1 needs to be built from the source. Unfortunately it requires iconv in order to be built correctly and doesn't see neither system iconv nor libiconv from ports. Clinton R. Nixon from Vidget Labs offers his own solution involving source libiconv installation. It works very well but the problem can also be solved by configuring Sphinx with additional parameters.

So, if you see something like that in make output:

Undefined symbols:
  "_iconv_close", referenced from:
      xmlUnknownEncoding(void*, char const*, XML_Encoding*)in libsphinx.a(sphinx.o)
  "_iconv", referenced from:
      xmlUnknownEncoding(void*, char const*, XML_Encoding*)in libsphinx.a(sphinx.o)
  "_iconv_open", referenced from:
      xmlUnknownEncoding(void*, char const*, XML_Encoding*)in libsphinx.a(sphinx.o)

Then use the following configure parameters (you can change prefix, of course):

CPPFLAGS="$CPPFLAGS -I/opt/local/include" \
LIBS="$LIBS -L/opt/local/lib" \
./configure --with-mysql=/opt/local/lib/mysql5/ \
--prefix=/opt/sphinx-0.9.9-rc1

After that, make and make install as usual.

P.S. I didn't try it with system iconv, only with libiconv from ports, as I already had it installed.