1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WebAssembly版 OpenCVのビルドでwasmが生成されなかった話

Posted at

問題点

下記チュートリアルに従いWASM版をビルドしたが、.wasmが生成されない。

https://docs.opencv.org/4.7.0/d4/da1/tutorial_js_setup.html

解決策

オプション'--disable_single_file'を追加する。

オプション'--build_wasm'だけでは、WASMはbase64化されて単一のjsファイルに埋め込まれて出力される。

4.7.0-devのドキュメントにはこの点についての記載があった。
https://docs.opencv.org/4.x/d4/da1/tutorial_js_setup.html

The build script builds asm.js version by default. To build WebAssembly version, append --build_wasm switch. By default everything is bundled into one JavaScript file by base64 encoding the WebAssembly code. For production builds you can add --disable_single_file which will reduce total size by writing the WebAssembly code to a dedicated .wasm file which the generated JavaScript file will automatically load.

その他

Dockerでビルドする場合、2023/4/12現在、タグ指定なしだとビルドに失敗するため、Warning に書かれている通り、emscripten/emsdk:2.0.10を使用する。

docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk:2.0.10 emcmake python3 ./platforms/js/build_js.py build_wasm --build_wasm --disable_single_file

参考

参考にさせていただいた記事

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?