Mac OS X 编译 sphinx 的一问题解决办法
昨天研究了一下 sphinx,回家在 Mac OS X 下用同样的方式编译 sphinx 时发生错误,
svn export http://sphinxsearch.googlecode.com/svn/trunk sphinx
cd sphinx
./configure --prefix=/usr/local/sphinx --with-mysql
make
...
sphinxstd.cpp: In function ‘bool sphIsLtLib()’:
sphinxstd.cpp:1001: error: ‘_CS_GNU_LIBPTHREAD_VERSION’ was not declared in this scope
make[2]: *** [sphinxstd.o] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1
最终在 sphinx 的 bug list 下找到该问题的解决办法 (bug #515)。
编辑 sphinx/src/sphinxstd.cpp,找到方法 sphIsLtLib(),修改该函数部分:
#if !USE_WINDOWS
bool sphIsLtLib()
{
#ifndef _CS_GNU_LIBPTHREAD_VERSION
return false;
// #endif // 删除该行, 增加下一行
#else
char buff[64];
confstr ( _CS_GNU_LIBPTHREAD_VERSION, buff, 64 );
if ( !strncasecmp ( buff, "linuxthreads", 12 ) )
return true;
return false;
#endif // 增加此行
}
#endif
然后重新 make 即可编译成功。