1

在 MAMP 本地开发,需要 Sphinx 与 MAMP 的 MySQL 一起工作。期间基本陷入死胡同$ sudo make

MAMP 安装时没有一些用于 Sphinx 集成的必要资源,主要是一个 mysql lib 目录和一个包含 C 头源文件的包含目录。这些已成功下载并安装(使用 CMake)到以下目录中:

/Applications/MAMP/Library/include/mysql
/Applications/MAMP/Library/lib/mysql

解压 Sphinx 并运行后:

sudo ./configure --prefix=/usr/local/sphinx --with-libstemmer --with-mysql=/Applications/MAMP/Library

我有:

******************************************************************************
ERROR: cannot find MySQL include files.

Check that you do have MySQL include files installed.
The package name is typically 'mysql-devel'.

If include files are installed on your system, but you are still getting
this message, you should do one of the following:

1) either specify includes location explicitly, using --with-mysql-includes;
2) or specify MySQL installation root location explicitly, using --with-mysql;
3) or make sure that the path to 'mysql_config' program is listed in

将 ./configure 命令更改为:

sudo ./configure --prefix=/usr/local/sphinx--with-libstemmer --with-mysql-includes /Applications/MAMP/Library/include --with-mysql-libs /Applications/MAMP/Library/lib

一开始就抛出以下内容,但无论如何都会导致配置成功:

configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type: /Applications/MAMP/Library/include
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type: /Applications/MAMP/Library/lib

该日志还具有以下行(我认为这是相关的):

checking MySQL include files... -Iyes

现在,继续,$ sudo make抛出以下内容:

Making all in src
/bin/sh svnxrev.sh ..
make  all-am
g++ -DHAVE_CONFIG_H -I. -I../config  -DSYSCONFDIR="\"/usr/local/sphinx--with-libstemmer/etc\"" -DDATADIR="\"/usr/local/sphinx--with-libstemmer/var/data\"" -I/usr/local/include -Iyes   -Wall -g -D_FILE_OFFSET_BITS=64 -O3 -DNDEBUG -MT sphinx.o -MD -MP -MF .deps/sphinx.Tpo -c -o sphinx.o sphinx.cpp
In file included from sphinx.cpp:16:
sphinx.h:64:19: error: mysql.h: No such file or directory

... //whole bunch of errors follow, resulting from the above

所以,我知道 mysql.h 存在于我的包含文件中,我想我也有所有必要的二进制文件,并且配置似乎看到了包含文件,所以我有点担心。我希望这是一个简单的路径问题,或者是我的 ./configure 属性的语法错误,因为这是我第一次从命令行编译和安装。

谢谢。

4

1 回答 1

1

Sphinx./configure使用未知的默认值--with-mysql,默认情况下启用,这可能会让您认为没有必要调用它。

要让 Sphinx 使用 MAMP 的不同分布的 MySQL 文件,请确保在您的./configure命令中使用以下每个属性,并为每个属性指定直接路径:

--with-mysql= // root mysql app
--with-includes= // path to mysql header includes
--with-mysql-libs= // path to libmysqlclient.dylib files

对我有用的最终命令:

./configure --prefix=/usr/local/sphinx --with-libstemmer --with-mysql=/Applications/MAMP/Library --with-mysql-includes=/Applications/MAMP/Library/include/mysql --with-mysql-libs=/Applications/MAMP/Library/lib/mysql

--prefix是您在 usr/local 中的首选安装目录,并--libstemmer添加了 Snowball 的扩展词干提取功能(如果您下载了它)。

如果这运行没有错误,make那么make install你就可以开始了。

另请注意,未压缩的 Sphinx 目录中有一个易于忽略的配置错误日志。在这种情况下没有帮助,但如果您遇到问题,可能对其他人非常有用。

于 2012-05-14T17:11:07.440 回答