emscriptenでopencvをwasmにコンパイル

実行環境

  • OS: ubuntu 20.04 (x86_64)
  • opencv4 github latest (commit a3e7c2d8e3ebb32a5ee58c8f3265dacead318572)
  • emscripten sdk-fastcomp-1.38.31-64bit
takahiro@ubuntu:~/Downloads/emsdk-master$ source emsdk_env.sh
Setting environment variables:
EMSDK = /home/takahiro/Downloads/emsdk-master
LLVM_ROOT = /home/takahiro/Downloads/emsdk-master/fastcomp-clang/e1.38.31_64bit
EMSCRIPTEN_NATIVE_OPTIMIZER = /home/takahiro/Downloads/emsdk-master/fastcomp-clang/e1.38.31_64bit/optimizer
BINARYEN_ROOT = /home/takahiro/Downloads/emsdk-master/fastcomp-clang/e1.38.31_64bit/binaryen
EMCC_WASM_BACKEND = 0
EMSDK_NODE = /home/takahiro/Downloads/emsdk-master/node/8.9.1_64bit/bin/node
EM_CACHE = /home/takahiro/Downloads/emsdk-master/emscripten/1.38.31/cache
EMSCRIPTEN = /home/takahiro/Downloads/emsdk-master/emscripten/1.38.31

コマンド

source emsdk_env.sh

cd opencv
emcc --clear-cache
python ./platforms/js/build_js.py build_wasm --build_wasm

ビルドログ(抜粋)

[100%] Generating ../../bin/opencv.js
cd /home/takahiro/Downloads/opencv/build_wasm/modules/js && /usr/bin/python2.7 /
home/takahiro/Downloads/opencv/modules/js/src/make_umd.py /home/takahiro/Downloa
ds/opencv/build_wasm/bin/opencv_js.js /home/takahiro/Downloads/opencv/build_wasm
/bin/opencv.js
make[3]: Leaving directory '/home/takahiro/Downloads/opencv/build_wasm'
[100%] Built target opencv.js
make[2]: Leaving directory '/home/takahiro/Downloads/opencv/build_wasm'
/usr/bin/cmake -E cmake_progress_start /home/takahiro/Downloads/opencv/build_was
m/CMakeFiles 0
make[1]: Leaving directory '/home/takahiro/Downloads/opencv/build_wasm'
=====
===== Build finished
=====
OpenCV.js location: /home/takahiro/Downloads/opencv/build_wasm/bin/opencv.js

参考

installing fastcompなのは、ただのlatest(LLVM?)だと、コンパイル後のリンクで__tls_baseがないとエラーになるから。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です