Compilation into WebAssembly fails
zavalyshyn opened this issue · comments
Hi,
First of all, thanks for making this project available to everyone. That's a fantastic job.
I'm trying to compile pocketsphinx.js into a WebAssembly as explained here and the build goes fine up until it fails when trying to find a file or a folder. The problem I can't find where exactly it fails. Maybe you can help?
make
Scanning dependencies of target pocketsphinx
[ 1%] Building CXX object CMakeFiles/pocketsphinx.dir/src/psRecognizer.cpp.o
em++: warning: linker flag ignored during compilation: '--bind' [-Wunused-command-line-argument]
/home/zavalyshyn/Documents/phd/smartcare/dev/hubos-dev/speech-recogn-wasm/pocketsphinx.js/src/psRecognizer.cpp:269:66: warning: unsequenced modification and access to 'index' [-Wunsequenced]
strings_set->insert(list.substr(index+1, -1 -index +(index = list.find(separator, index + 1))));
~~~~~ ^
1 warning generated.
em++: warning: argument unused during compilation: '-lembind' [-Wunused-command-line-argument]
[ 2%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/acmod.c.o
[ 3%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/bin_mdef.c.o
[ 5%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/blkarray_list.c.o
[ 6%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/dict.c.o
[ 7%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/dict2pid.c.o
[ 9%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/fsg_history.c.o
[ 10%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/fsg_lextree.c.o
[ 11%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/fsg_search.c.o
[ 12%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/hmm.c.o
[ 14%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/mdef.c.o
[ 15%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ms_gauden.c.o
[ 16%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ms_mgau.c.o
[ 18%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ms_senone.c.o
[ 19%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ngram_search.c.o
[ 20%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ngram_search_fwdtree.c.o
[ 22%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ngram_search_fwdflat.c.o
[ 23%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/phone_loop_search.c.o
[ 24%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/pocketsphinx.c.o
[ 25%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ps_lattice.c.o
[ 27%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ps_mllr.c.o
[ 28%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/ptm_mgau.c.o
[ 29%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/s2_semi_mgau.c.o
[ 31%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/tmat.c.o
[ 32%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/vector.c.o
[ 33%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/kws_search.c.o
[ 35%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/kws_detections.c.o
[ 36%] Building C object CMakeFiles/pocketsphinx.dir/pocketsphinx/src/libpocketsphinx/allphone_search.c.o
[ 37%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fe_interface.c.o
[ 38%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fe_sigproc.c.o
[ 40%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fe_warp_affine.c.o
[ 41%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fe_warp.c.o
[ 42%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fe_warp_inverse_linear.c.o
[ 44%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fe_warp_piecewise_linear.c.o
[ 45%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fixlog.c.o
[ 46%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fe_noise.c.o
[ 48%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/fe/fe_prespch_buf.c.o
[ 49%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/feat/agc.c.o
[ 50%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/feat/cmn.c.o
[ 51%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/feat/cmn_live.c.o
[ 53%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/feat/feat.c.o
[ 54%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/feat/lda.c.o
[ 55%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/fsg_model.c.o
[ 57%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/jsgf.c.o
[ 58%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/jsgf_parser.c.o
[ 59%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/jsgf_scanner.c.o
[ 61%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/ngrams_raw.c.o
[ 62%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/lm_trie.c.o
[ 63%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/lm_trie_quant.c.o
[ 64%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/ngram_model_set.c.o
[ 66%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/ngram_model_trie.c.o
[ 67%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/lm/ngram_model.c.o
[ 68%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/bio.c.o
[ 70%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/bitvec.c.o
[ 71%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/case.c.o
[ 72%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/ckd_alloc.c.o
[ 74%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/cmd_ln.c.o
[ 75%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/dtoa.c.o
[ 76%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/err.c.o
[ 77%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/errno.c.o
[ 79%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/f2c_lite.c.o
[ 80%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/filename.c.o
[ 81%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/genrand.c.o
[ 83%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/glist.c.o
[ 84%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/hash_table.c.o
[ 85%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/heap.c.o
[ 87%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/listelem_alloc.c.o
[ 88%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/logmath.c.o
[ 89%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/matrix.c.o
[ 90%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/mmio.c.o
[ 92%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/pio.c.o
[ 93%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/profile.c.o
[ 94%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/sbthread.c.o
[ 96%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/strfuncs.c.o
[ 97%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/bitarr.c.o
[ 98%] Building C object CMakeFiles/pocketsphinx.dir/sphinxbase/src/libsphinxbase/util/priority_queue.c.o
[100%] Linking CXX shared library libpocketsphinx.so
em++: warning: linking a library with `-shared` will emit a static object file. This is a form of emulation to support existing build systems. If you want to build a runtime shared library use the SIDE_MODULE setting. [-Wemcc]
em++: warning: ignoring unsupported linker flag: `-soname` [-Wlinkflags]
[100%] Built target pocketsphinx
Scanning dependencies of target pocketsphinx.js
emcc: error: : No such file or directory (" " was expected to be an input file, based on the commandline arguments provided)
make[2]: *** [CMakeFiles/pocketsphinx.js.dir/build.make:57: CMakeFiles/pocketsphinx.js] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/pocketsphinx.js.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
I found the problem.
A file build.make
located at pocketsphinx.js/build/CMakeFiles/pocketsphinx.js.dir
contained a weird \
symbol in the end of line 57. And if I'm not mistaken it should not be there since there are no other commands for that make target afterwards.
CMakeFiles/pocketsphinx.js: libpocketsphinx.so
/home/zavalyshyn/Documents/phd/smartcare/dev/emsdk/upstream/emscripten/emcc -Oz -s WASM=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s TOTAL_MEMORY=100663296 --bind --memory-init-file 0 libpocketsphinx.so -o pocketsphinx.js --embed-file rm1_200 \
pocketsphinx.js: CMakeFiles/pocketsphinx.js
pocketsphinx.js: CMakeFiles/pocketsphinx.js.dir/build.make
Deleting that \
symbol and re-running make results in a successful build of pocketsphinx.wasm and pocketshpinx.js files.
Hope it helps