sz3 / libcimbar

Optimized implementation for color-icon-matrix barcodes
https://cimbar.org
Mozilla Public License 2.0
4.22k stars 306 forks source link

What files are needed to compile the wasm for HTML, and what other parameters are needed? #74

Closed DebugNoob closed 1 year ago

DebugNoob commented 1 year ago

HI, your project is amazing to me. I want to try modifying some parameters to compile wasm and encountered some issues. What files are needed to compile the wasm for HTML, and what other parameters are needed?

sz3 commented 1 year ago

For the wasm build (and the asm.js build), I use a docker container and run this script inside it. The docker command is the (commented out) 2nd line of the script: https://github.com/sz3/libcimbar/blob/master/package-wasm.sh

You can also see how it's used by the github actions workflow here. The only real interesting thing is that you need to download opencv and extract it to the opencv4/ subdirectory ahead of time.

DebugNoob commented 1 year ago

Thank you very much ^_^. But I have encountered a new problem that I searched the internet but couldn't find the relevant answer. Have you encountered it again? When I execute to make -j5 install

[ 61%] Building CXX object build/src/third_party_lib/wirehair/CMakeFiles/wirehair.dir/wirehair.cpp.o
clang++: error: unsupported option '-march=' for target 'wasm32-unknown-emscripten'
em++: error: '/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN --sysroot=/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -DLIBCIMBAR_PROJECT_ROOT="/usr/src/app" -I/usr/src/app/opencv4/include -I/usr/src/app/opencv4/opencv-build-wasm/build_wasm -I/usr/src/app/opencv4/modules/calib3d/include -I/usr/src/app/opencv4/modules/core/include -I/usr/src/app/opencv4/modules/dnn/include -I/usr/src/app/opencv4/modules/features2d/include -I/usr/src/app/opencv4/modules/flann/include -I/usr/src/app/opencv4/modules/gapi/include -I/usr/src/app/opencv4/modules/highgui/include -I/usr/src/app/opencv4/modules/imgcodecs/include -I/usr/src/app/opencv4/modules/imgproc/include -I/usr/src/app/opencv4/modules/ml/include -I/usr/src/app/opencv4/modules/objdetect/include -I/usr/src/app/opencv4/modules/photo/include -I/usr/src/app/opencv4/modules/stitching/include -I/usr/src/app/opencv4/modules/ts/include -I/usr/src/app/opencv4/modules/video/include -I/usr/src/app/opencv4/modules/videoio/include -I/usr/src/app/opencv4/modules/world/include -I/usr/src/app/src/lib -I/usr/src/app/src/third_party_lib -I/usr/src/app/src/third_party_lib/wirehair/include -DGF256_TARGET_MOBILE -march=native -Os -std=gnu++11 -MD -MT build/src/third_party_lib/wirehair/CMakeFiles/wirehair.dir/wirehair.cpp.o -MF CMakeFiles/wirehair.dir/wirehair.cpp.o.d -c /usr/src/app/src/third_party_lib/wirehair/wirehair.cpp -o CMakeFiles/wirehair.dir/wirehair.cpp.o' failed (returned 1)
make[2]: *** [build/src/third_party_lib/wirehair/CMakeFiles/wirehair.dir/build.make:77: build/src/third_party_lib/wirehair/CMakeFiles/wirehair.dir/wirehair.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:669: build/src/third_party_lib/wirehair/CMakeFiles/wirehair.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

😢

sz3 commented 1 year ago

Ok, I'm seeing the same error when using emscripten/emsdk:latest. Thanks for noticing this... I think we need to use a (slightly) older emscripten image.

sz3 commented 1 year ago

emscripten/emsdk:3.1.39 works.

sz3 commented 1 year ago

https://github.com/sz3/libcimbar/pull/75

DebugNoob commented 1 year ago

Thank you very much! Wishing you great success in your future work!