Mecab と CaboCha を windows7上で python(python2.7)から使う目的で、インストール作業をしています。
・MecabとCabochaは、それぞれインストールできて、Windows上のコマンドプロンプトで動作するのですが、
・MecabとCabocha のpython バインディングスのインストールがうまくいきません。
Mecab、Cabocha 及び その Pythonバインディングスの windowsでのインストールについては、ネット上に(エラー対応を含めて)解説が
http://seesaawiki.jp/spz/d/Windows%A4%CBmecab-python%A4%F2%C6%B3%C6%FE
等、いくつもあって、共通して出ている setup.py の修正まではいいのですが、その後、
python setup.py install
とやると、下記のようになります。
C:\JNLP\work\Mecab\mecab-python-0.996>python setup.py install
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying MeCab.py -> build\lib.win32-2.7
running build_ext
building '_MeCab' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Program1\MeCab\sdk -IC:\Anaconda2\include -IC:\Anaconda2\PC -c MeCab_wrap.cxx -o build\temp.win32-2.7\Release\mecab_wrap.o
MeCab_wrap.cxx: In function 'void init_MeCab()':
MeCab_wrap.cxx:8309:21: warning: variable 'md' set but not used [-Wunused-but-set-variable]
PyObject *m, *d, *md;
^
writing build\temp.win32-2.7\Release_MeCab.def
ここまでは、(Mecabでは warningはありますが、Cabichaはwraningもなく、)動いて、それぞれ「Mecab.def」,「_Cabocha.def」はできるのですが、続いて、
C:\MinGW\bin\g++.exe -shared -s build\temp.win32-2.7\Release\mecab_wrap.o build\temp.win32-2.7\Release_MeCab.def -LC:\Program1\MeCab\sdk -LC:\Anaconda2\libs -LC:\Anaconda2\PCbuild -LC:\Anaconda2\PC\VS9.0 -llibmecab -lpython27 -lmsvcr90 -obuild\lib.win32-2.7_MeCab.pyd
build\temp.win32-2.7\Release\mecab_wrap.o:MeCab_wrap.cxx:(.text+0x151d): undefined reference to _imp___ZN5MeCab13createLatticeEv' build\temp.win32-2.7\Release\mecab_wrap.o:MeCab_wrap.cxx:(.text+0x249b): undefined reference to
MeCab::Model::version()'
build\temp.win32-2.7\Release\mecab_wrap.o:MeCab_wrap.cxx:(.text+0x2af6): undefined reference to `MeCab::Tagger::version()'
: (同じような 「undefined reference」が続く)
build\temp.win32-2.7\Release\mecab_wrap.o:MeCab_wrap.cxx:(.text+0xae60): undefined reference to _imp___ZN5MeCab12getLastErrorEv' build\temp.win32-2.7\Release\mecab_wrap.o:MeCab_wrap.cxx:(.text+0xb18b): undefined reference to
_imp___ZN5MeCab13createLatticeEv'
collect2.exe: error: ld returned 1 exit status
error: command 'C:\MinGW\bin\g++.exe' failed with exit status 1
とエラーになります。Cabochaもほぼ同じメッセージの流れで同様のエラーで終了します。
Anaconda/python2.7、MINGW がインストールされている環境で、C コンパイラ/リンカは、MINGW上のgcc, g++ が起動されます。
尚、ネット上の解説では、VisualStudioのインストール、環境変数「VS90COMNTOOLS」の Visual Studioのアドレスへの書き換え指示があったので、インストール済みのVisualStudio12のアドレスに書き換えましたが、gcc, g++ が動きます。
MeCabもCabochaも共通の原因だと思いますが、どのような対処をすればよいか、アドバイスをお願いします。
※ MeCabのPythonバインディングスについては、http://qiita.com/buruzaemon/items/975027cea6371b2c5ec3で紹介されている「natto-py」というツールで、簡単にPythonバインディングスはできたのですが、Cabochaでは使えないので、MeCabとCabochaに共通のPythonバインディングスを何とかしたいと思います。
あなたの回答
tips
プレビュー