在Windows上构建pyhunspell

时间:2014-07-23 18:03:49

标签: python mingw mingw-w64 hunspell

我在Windows上使用64位Python 2.7

我已下载hunspellpyhunspell

使用64位MinGW系统我成功编译了hunspell项目 - 导致工作的可执行hu​​nspell工具和hunspell库。在构建之后,这是我的文件夹结构:

+---hunspell-0.1
\---hunspell-1.3.3
    +---intl
    +---m4
    +---man
    |   \---hu
    +---po
    +---src
    |   +---hunspell
    |   |   +---.deps
    |   |   \---.libs
    |   +---parsers
    |   |   +---.deps
    |   |   \---.libs
    |   +---tools
    |   |   +---.deps
    |   |   \---.libs
    |   \---win_api
    \---tests
        \---suggestiontest

在文件夹hunspell-0.1中,我有pyhunspell项目。我打开setup.py文件并将其更改为:

main = Extension('hunspell',
                 libraries = ['../hunspell-1.3.3/src/hunspell/.libs/hunspell-1.3'],
                 include_dirs = ['../hunspell-1.3.3/src/hunspell'],
                 sources = ['hunspell.c'],
                 extra_compile_args = ['-Wall'])

执行python setup.py build -c mingw32会导致:build log以错误消息结尾:

c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-mingw_helpers.o): bad reloc address 0x0 in section ".pdata"'

任何想法可能是什么问题?

1 个答案:

答案 0 :(得分:0)

我以一种奇怪的方式制作了Python包:

  1. 使用以下行更改了setup.py

    libraries = ['../hunspell-1.3.3/src/hunspell/.libs/libhunspell-1.3']

  2. 重命名

    hunspell-1.3.3/src/hunspell/.libs/libhunspell-1.3.dll.a

    hunspell-1.3.3/src/hunspell/.libs/libhunspell-1.3.lib

  3. 使用默认编译器编译 - MSVC:

    python setup.py build

    python setup.py install

  4. 复制

    hunspell-1.3.3/src/hunspell/.libs/libhunspell-1.3-0.dll

    到site-packages。

  5. 导入。