Compiling Sphinx on Mac OS X

We are looking into using Sphinx on a project and needed to get it installed on our local machines, Macbook Pros, for exploration. Sphinx does not ship Mac binaries, so we had to compile it. We had XCode previously installed. If you want the MySQL to connect, you need to download the source files to the version of MySQL you are running.

The first step is to run Cmake from within the MySQL source directory. Specifically, it generates a mysql_version.h file from  You probably have to download Cmake.

 cmake -DBUILD_CONFIG=mysql_release

You only need to make the MySQL client libraries, so cd into libmysql directory

cd libmysql

This will compile and link the necessary files into a libary for Sphinx to use.

Once these complete successfully, now you can follow sphinx’s compilation directions.

./configure --prefix=/Applications/sphinx/2.0.3/sphinx-2.0.3 --with-mysql-includes=/Applications/sphinx/2.0.3/mysql-5.5.9/include --with-mysql-libs=/Applications/sphinx/2.0.3/mysql-5.5.9/libmysql

You can see I downloaded the Sphinx and MySQL 5.5.9 sources to a directory buried in the Applications directory. I specified the includes directory as well as the client directory. Change these to your paths as needed. When its complete, you should have a bunch of new directories and files in the –prefix path. searchd is the search daemon in the bin directory.

Now, its off to try and leverage Sphinx!

UPDATE: I want to point out that you should typically compile the thread safe versions if the MySQL client. The Cmake script configures to compile both, thread safe and thread unsafe. I assume sphinx uses the thread-safe libraries, or at least knows its using unsafe versions on purpose. Hit tip to Chris Sebastian.

Leave a Reply

Your email address will not be published. Required fields are marked *