按照kaldi/windows/INSTALL.md中的教程来。
首先,系统上要装有cmake,vs2017,git等
执行下面代码,安装编译openfst
$ git clone https://github.com/kkm000/openfst.git $ cd openfst $ mkdir build64 $ cd build64 $ cmake -G "Visual Studio 15 2017 Win64" ../
然后,原文说,最后一条指令通常将会输出看起来像下面一样的内容,不要进行过多的解读
-- The C compiler identification is MSVC 19.11.25547.0 -- The CXX compiler identification is MSVC 19.11.25547.0 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- The following ICU libraries were not found: -- data (required) -- i18n (required) -- io (required) -- test (required) -- tu (required) -- uc (required) -- Failed to find all ICU components (missing: ICU_INCLUDE_DIR ICU_LIBRARY _ICU_REQUIRED_LIBS_FOUND) -- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) -- Configuring done -- Generating done -- Build files have been written to: C:/Users/jtrmal/Documents/openfst/build64
但是,我运行却是这样的
-- Configuring done CMake Error at src/test/CMakeLists.txt:1 (add_executable): Cannot find source file: fst_test.h Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx CMake Error at src/test/CMakeLists.txt:9 (add_executable): Cannot find source file: weight-tester.h Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx CMake Error at src/test/CMakeLists.txt:33 (add_executable): Cannot find source file: algo_test.h Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx CMake Error at src/test/CMakeLists.txt:1 (add_executable): No SOURCES given to target: fst_test CMake Error at src/test/CMakeLists.txt:9 (add_executable): No SOURCES given to target: weight_test CMake Error at src/test/CMakeLists.txt:33 (add_executable): No SOURCES given to target: algo_test_minmax CMake Error at src/test/CMakeLists.txt:17 (add_executable): No SOURCES given to target: algo_test_log CMake Error at src/test/CMakeLists.txt:25 (add_executable): No SOURCES given to target: algo_test_tropical CMake Error at src/test/CMakeLists.txt:41 (add_executable): No SOURCES given to target: algo_test_lexicographic CMake Error at src/test/CMakeLists.txt:49 (add_executable): No SOURCES given to target: algo_test_power -- Build files have been written to: D:/mc/kaldi-1/openfst/build64
//发现几个.h文件找不到
打开CMakeLists.txt所在test文件,发现里面只有.cc文件没有CMakeList.txt中需要的几个.h
去src/include/fst/test文件夹下,找到这几个库,复制过来,再次编译
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18362. -- The following ICU libraries were not found: -- data (required) -- i18n (required) -- io (required) -- test (required) -- tu (required) -- uc (required) -- Failed to find all ICU components (missing: ICU_INCLUDE_DIR ICU_LIBRARY _ICU_REQUIRED_LIBS_FOUND) -- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) -- D:/mc/kaldi-1/openfst/src/script/../include/fst/script/arc-class.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/arciterator-class.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/arcsort.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/arg-packs.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/closure.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/compile-impl.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/compile.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/compose.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/concat.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/connect.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/convert.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/decode.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/determinize.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/difference.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/disambiguate.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/draw-impl.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/draw.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/encode.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/encodemapper-class.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/epsnormalize.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/equal.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/equivalent.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/fst-class.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/fstscript-decl.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/fstscript.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/getters.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/info-impl.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/info.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/intersect.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/invert.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/isomorphic.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/map.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/minimize.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/print-impl.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/print.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/project.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/prune.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/push.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/randequivalent.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/randgen.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/register.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/relabel.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/replace.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/reverse.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/reweight.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/rmepsilon.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/script-impl.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/shortest-distance.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/shortest-path.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/stateiterator-class.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/synchronize.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/text-io.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/topsort.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/union.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/verify.h;D:/mc/kaldi-1/openfst/src/script/../include/fst/script/weight-class.h -- D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/compile-strings.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/create.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/equal.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/extract.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/far-class.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/far.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/farlib.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/farscript.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/getters.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/info.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/isomorphic.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/print-strings.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/script-impl.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/stlist.h;D:/mc/kaldi-1/openfst/src/extensions/far/../../include/fst/extensions/far/sttable.h -- D:/mc/kaldi-1/openfst/src/extensions/linear/../../include/fst/extensions/linear/linear-fst-data-builder.h;D:/mc/kaldi-1/openfst/src/extensions/linear/../../include/fst/extensions/linear/linear-fst-data.h;D:/mc/kaldi-1/openfst/src/extensions/linear/../../include/fst/extensions/linear/linear-fst.h;D:/mc/kaldi-1/openfst/src/extensions/linear/../../include/fst/extensions/linear/linearscript.h;D:/mc/kaldi-1/openfst/src/extensions/linear/../../include/fst/extensions/linear/loglinear-apply.h;D:/mc/kaldi-1/openfst/src/extensions/linear/../../include/fst/extensions/linear/trie.h -- D:/mc/kaldi-1/openfst/src/extensions/mpdt/../../include/fst/extensions/mpdt/compose.h;D:/mc/kaldi-1/openfst/src/extensions/mpdt/../../include/fst/extensions/mpdt/expand.h;D:/mc/kaldi-1/openfst/src/extensions/mpdt/../../include/fst/extensions/mpdt/info.h;D:/mc/kaldi-1/openfst/src/extensions/mpdt/../../include/fst/extensions/mpdt/mpdt.h;D:/mc/kaldi-1/openfst/src/extensions/mpdt/../../include/fst/extensions/mpdt/mpdtlib.h;D:/mc/kaldi-1/openfst/src/extensions/mpdt/../../include/fst/extensions/mpdt/mpdtscript.h;D:/mc/kaldi-1/openfst/src/extensions/mpdt/../../include/fst/extensions/mpdt/read_write_utils.h;D:/mc/kaldi-1/openfst/src/extensions/mpdt/../../include/fst/extensions/mpdt/reverse.h -- D:/mc/kaldi-1/openfst/src/extensions/ngram/../../include/fst/extensions/ngram/bitmap-index.h;D:/mc/kaldi-1/openfst/src/extensions/ngram/../../include/fst/extensions/ngram/ngram-fst.h;D:/mc/kaldi-1/openfst/src/extensions/ngram/../../include/fst/extensions/ngram/nthbit.h -- D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/collection.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/compose.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/expand.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/getters.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/info.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/paren.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/pdt.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/pdtlib.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/pdtscript.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/replace.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/reverse.h;D:/mc/kaldi-1/openfst/src/extensions/pdt/../../include/fst/extensions/pdt/shortest-path.h -- D:/mc/kaldi-1/openfst/src/extensions/special/../../include/fst/extensions/special/phi-fst.h;D:/mc/kaldi-1/openfst/src/extensions/special/../../include/fst/extensions/special/rho-fst.h;D:/mc/kaldi-1/openfst/src/extensions/special/../../include/fst/extensions/special/sigma-fst.h -- Configuring done -- Generating done -- Build files have been written to: D:/mc/kaldi-1/openfst/build64
Done,应该没问题了,编译后的文件被写在build64文件夹下。
接下来照着他说的编译
In the directory build64
, find the file openfst.sln
and open it using Visual Studio 17.
Switch the configuration to Debug|x64
and build the solution. Do the same for configuration Release|x64
.
If either of the two won‘t build, you should stop here and start figuring what‘s different!
用vs2017打开,配置成Debug|x64,然后build解决方案。
这里成功生成。项目没有主函数,只是一些库,所以不能运行。
关于Debug|x64 Release|x64的区别,见https://www.cnblogs.com/netserver/p/11106130.html