最近在一台新的liunx服务器上安装sphinx,make后报出如下的错误:
/usr/local/src/sphinx-2.3.1-beta/src/sphinx.cpp:28788: undefined reference to `libiconv_open'
/usr/local/src/sphinx-2.3.1-beta/src/sphinx.cpp:28806: undefined reference to `libiconv'
/usr/local/src/sphinx-2.3.1-beta/src/sphinx.cpp:28812: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
make[2]: *** [indexer] Error 1
make[2]: Leaving directory `/usr/local/src/sphinx-2.3.1-beta/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/local/src/sphinx-2.3.1-beta/src'
make: *** [all-recursive] Error 1
在网上百度到有三种解决办法:
第一种:
打开configure文件,找到#define USE_LIBICONV 1
,将注释去掉,并将1改成0。
第二种:
编辑:./src/MakeFile
文件
将LIBS = -lm -lexpat -L/usr/local/lib
改成
LIBS = -lm -lexpat -liconv -L/usr/local/lib
第三种:
直接修改 src/sphinx.cpp,将iconv.h 改为绝对路径。
I have the same problem, and I change #include "iconv.h" to #include <iconv.h> to
#include </usr/include/iconv.h>
我采取第三种方式最终解决问题。