我在python 3.2 virtualenv中为hunspell库安装pyhunspell绑定时遇到问题。我从here下载了hunspell。我发布了./configure
和make
,它运行正常。我避免做make install
,因为我的目的是在web服务器上安装virtualenv,我没有root权限。
因此我下载了pyhunspell bindings并将其解压缩到创建hunspell的目录中。我通过添加正确的目标修改了include_dir
中的setup.py
路径并应用了允许使用Python 3构建pyhunspell的patch。然后我运行python setup.py install
(之前已激活目标virtualenv) ),但我得到了这个:
$ python setupy.py install
running install
running build
running build_ext
building 'hunspell' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -D_LINUX -I./src/hunspell -I/usr/include/hunspell -I/usr/include/python3.2mu -c hunspell.c -o build/temp.linux-x86_64-3.2/hunspell.o -Wall
creating build/lib.linux-x86_64-3.2
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-3.2/hunspell.o -lhunspell-1.2 -o build/lib.linux-x86_64-3.2/hunspell.cpython-32mu.so
/usr/bin/ld: cannot find -lhunspell-1.2
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
链接器似乎无法链接,因为它在系统路径中查找它,而我没有在系统中安装库。在C的奥秘中,有人比我更聪明,可以解决这个问题吗?
我会补充一点,我还没有真正的服务器访问权限,但我知道它的系统与我的本地系统非常类似(Debian 7.0 Wheezy),所以我决定先尝试一下登录服务器。是否有可能在我的计算机上编译的库也可以在服务器上运行,假设它也可能是某些(稳定的)可能的Debian版本?
答案 0 :(得分:1)
没有必要建立Hunspell。安装Wheezy软件包libhunspell-1.3-0和libhunspell-dev。它应该与HunSpell 1.3一起使用。只需修改setup.py即可使用libraries = ['hunspell']
。
仅供参考,发布的补丁有问题。它将HunSpell
的方法添加为模块函数。这些接收模块作为第一个参数而不是预期的HunSpell
实例。例如,如果您调用hunspell.spell
,则该过程在尝试使用self->handle
时可能会出现段错误。您应该修复PyModuleDef
以摆脱这些错误功能。将hunspell.c的第273行更改为使用NULL
而不是HunSpell_methods
。