Open kent-h opened 4 years ago
I'm not familiar with Windows, but it looks that the linker can't find the reference to getopt_internal
.
Can I have the version of your MinGW?
My version of MinGW is:
$ uname -a
MINGW64_NT-10.0-18363 Kent-Desk 3.0.7-338.x86_64 2019-11-21 23:07 UTC x86_64 Msys
I tried updating gcc, and was able to get further. It's now failing with:
checking if g++ environment provides all required features... no
configure: error: Your compiler is not powerful enough to compile MeCab.
If it should be, see config.log for more information of why it failed.
Latest config.log
Is your GCC TDM-GCC ? https://jmeubank.github.io/tdm-gcc/ MSYS2 provides pre-build packages including MinGW, so I recommend you to use it.
Here is my test code: https://github.com/shogo82148/mecab/blob/master/.github/workflows/test-mingw.yml
I'm now using MSYS2 as suggested, and trying to follow your script as closely as possible. Was able to get ./configure to run without problems, but ran into issues while running make all
:
libtool: compile: x86_64-w64-mingw32-g++ -DHAVE_CONFIG_H -I. -I.. -DDIC_VERSION=102 "-DMECAB_DEFAULT_RC=\"c:\\\\Program Files\\\\mecab\\\\etc\\\\mecabrc\"" -I/mingw64/include -O3 -Wall -Wextra -municode -DUNICODE -D_UNICODE -DDLL_EXPORT -c libmecab.cpp -o libmecab.o >/dev/null 2>&1
/bin/sh ../libtool --tag=CXX --mode=link x86_64-w64-mingw32-g++ -O3 -Wall -Wextra -municode -DUNICODE -D_UNICODE -DDLL_EXPORT -no-undefined -version-info 2:1:0 -municode -o libmecab.la -rpath /mingw64/lib viterbi.lo tagger.lo utils.lo eval.lo iconv_utils.lo dictionary_rewriter.lo dictionary_generator.lo dictionary_compiler.lo context_id.lo connector.lo nbest_generator.lo writer.lo string_buffer.lo param.lo tokenizer.lo char_property.lo dictionary.lo feature_index.lo lbfgs.lo learner_tagger.lo learner.lo libmecab.lo -lpthread -lpthread -lstdc++ /mingw64/lib/libiconv.dll.a -L/mingw64/lib
*** Warning: Trying to link with static lib archive /mingw64/lib/libiconv.dll.a.
*** I have the capability to make that library automatically link in when
*** you link to this library. But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because the file extensions .a of this argument makes me believe
*** that it is just a static archive that I should not use here.
libtool: link: x86_64-w64-mingw32-g++ -shared -nostdlib C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/lib/../lib/dllcrt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/crtbegin.o .libs/viterbi.o .libs/tagger.o .libs/utils.o .libs/eval.o .libs/iconv_utils.o .libs/dictionary_rewriter.o .libs/dictionary_generator.o .libs/dictionary_compiler.o .libs/context_id.o .libs/connector.o .libs/nbest_generator.o .libs/writer.o .libs/string_buffer.o .libs/param.o .libs/tokenizer.o .libs/char_property.o .libs/dictionary.o .libs/feature_index.o .libs/lbfgs.o .libs/learner_tagger.o .libs/learner.o .libs/libmecab.o -lpthread -lpthread -lstdc++ -L/mingw64/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../.. -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/crtend.o -O3 -municode -municode -o .libs/libmecab-2.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libmecab.dll.a
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/iconv_utils.o:iconv_utils.cpp:(.text+0x18): undefined reference to `libiconv_close'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/iconv_utils.o:iconv_utils.cpp:(.text+0x4d): undefined reference to `libiconv_close'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/iconv_utils.o:iconv_utils.cpp:(.text+0x1f3): undefined reference to `libiconv_open'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/iconv_utils.o:iconv_utils.cpp:(.text+0x4c1): undefined reference to `libiconv'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/iconv_utils.o:iconv_utils.cpp:(.text+0x4eb): undefined reference to `libiconv'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [Makefile:604: libmecab.la] Error 1
make[2]: Leaving directory '/e/Kent/git/mecab/mecab/src'
make[1]: *** [Makefile:521: all-recursive] Error 1
make[1]: Leaving directory '/e/Kent/git/mecab/mecab'
make: *** [Makefile:387: all] Error 2
I found this post which tries to compile MeCab on MSYS2. https://www.reddit.com/r/C_Programming/comments/bgg2cf/issues_trying_to_compile_a_thirdparty_library/
In this post, the author says the following.
Thanks! Executing make LDFLAGS='liconv' worked!
I expect that the autoconf script (./configure
) will add -liconv
automatically, but it seems that the autoconf script doesn't on your environment.
I don't know why... 😕
I'm trying to build on Windows using MinGW (specifically MinGW64)
Unzipped mecab-0.996.3.tar.gz to mecab-0.996.3, then tried to run
./configure
This eventually fails with:
Looking for solutions hinted that this might be a python version issue. Tried with
2.7
,3.7
, &3.8
with no success.Please see the generated config.log
What might I be doing wrong?