opencv-rust icon indicating copy to clipboard operation
opencv-rust copied to clipboard

Add support for WASM target

Open Horki opened this issue 4 years ago • 24 comments

Before reporting an issue please first check the troubleshooting guide. If the issue you're encountering is not solved thereby please state the following in your bugreport:

  1. Operating system 5.6.10-arch1-1 GNU/Linux
  2. The way you installed OpenCV: package, official binary distribution, manual compilation, etc. via "packer" manager
  3. OpenCV version 4.3.0
  4. Attach the full output of the following command from your project directory:
    RUST_BACKTRACE=full cargo build -vv 
    

Version rustc 1.43.0 (4fb7144ed 2020-04-20)

Target wasm32-unknown-unknown

CLI cargo +stable build --release --target=wasm32-unknown-unknown

   Compiling num-traits v0.2.11
   Compiling opencv v0.34.0
error: failed to run custom build command for `opencv v0.34.0`

Caused by:
  process didn't exit successfully: `/home/horky/Documents/WorkspaceRust/cvwasm/target/release/build/opencv-e2dc348207d786b2/build-script-build` (exit code: 1)
--- stderr
=== Environment configuration:
===   OPENCV_HEADER_DIR = None
===   OPENCV_PACKAGE_NAME = None
===   OPENCV_PKGCONFIG_NAME = None
===   OPENCV_LINK_LIBS = None
===   OPENCV_LINK_PATHS = None
===   OPENCV_INCLUDE_PATHS = None
===   PKG_CONFIG_PATH = None
===   VCPKG_ROOT = None
=== Setting up OpenCV library from pkg_config
Error: "Package opencv4 is not found, caused by: Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override"

warning: build failed, waiting for other jobs to finish...
error: build failed

I didn't succeed to find a way of working OpenCV (rust+wasm) example on internet, is there a way to build it properly?

PS. Trivia I would like to rewrite my simple app from C++ intro rust

Horki avatar May 04 '20 20:05 Horki

Not that I have tested it in any way, but did you try doing what it suggested?

Use PKG_CONFIG_ALLOW_CROSS=1 to override

twistedfall avatar May 04 '20 20:05 twistedfall

Yes, I have but unsuccessfully. ( I also posted in the user group, in January)

log dump

   Compiling num v0.2.1
   Compiling opencv v0.34.0
error: failed to run custom build command for `opencv v0.34.0`

Caused by:
  process didn't exit successfully: `/home/horky/Documents/WorkspaceRust/cvwasm/target/release/build/opencv-e2dc348207d786b2/build-script-build` (exit code: 1)
--- stdout
cargo:rerun-if-env-changed=OPENCV_HEADER_DIR
cargo:rerun-if-env-changed=OPENCV_PACKAGE_NAME
cargo:rerun-if-env-changed=OPENCV_PKGCONFIG_NAME
cargo:rerun-if-env-changed=OPENCV_LINK_LIBS
cargo:rerun-if-env-changed=OPENCV_LINK_PATHS
cargo:rerun-if-env-changed=OPENCV_INCLUDE_PATHS
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=VCPKG_ROOT
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/dnn.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/videoio.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/core.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/manual-dnn.cpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/face.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/manual-core.cpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/aruco.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/ocvrs_resolve_types.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/manual-features2d.cpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/hdf.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/calib3d.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/ccalib.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/bioinspired.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/sfm.hpp
cargo:rerun-if-changed=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/imgproc.hpp
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/aruco.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/aruco.cpp"
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/calib3d.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/calib3d.cpp"
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/core.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/core.cpp"
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/ccalib.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/ccalib.cpp"
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/alphamat.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/alphamat.cpp"
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/bgsegm.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/bgsegm.cpp"
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/bioinspired.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/bioinspired.cpp"
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/manual-core.o" "-c" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/manual-core.cpp"
cargo:warning=In file included from /home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/aruco.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/aruco.hpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
running: "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/cvv.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/cvv.cpp"
cargo:warning=In file included from /home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/alphamat.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
cargo:warning=In file included from /home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/calib3d.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/calib3d.hpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
cargo:warning=In file included from /home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/bgsegm.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/manual-core.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/core.hpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
cargo:warning=In file included from /home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/bioinspired.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/bioinspired.hpp:3:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
cargo:warning=In file included from /home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/ccalib.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/ccalib.hpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
cargo:warning=In file included from /home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/core.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/core.hpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1
cargo:warning=In file included from /home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/cvv.cpp:1:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp/common.hpp:2:
cargo:warning=In file included from /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core.hpp:52:
cargo:warning=/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4/opencv2/core/cvdef.h:171:10: fatal error: 'limits' file not found
cargo:warning=#include <limits>
cargo:warning=         ^~~~~~~~
cargo:warning=1 error generated.
exit code: 1

--- stderr
=== Environment configuration:
===   OPENCV_HEADER_DIR = None
===   OPENCV_PACKAGE_NAME = None
===   OPENCV_PKGCONFIG_NAME = None
===   OPENCV_LINK_LIBS = None
===   OPENCV_LINK_PATHS = None
===   OPENCV_INCLUDE_PATHS = None
===   PKG_CONFIG_PATH = None
===   VCPKG_ROOT = None
=== Setting up OpenCV library from pkg_config
=== OpenCV library configuration: Library {
    pkg_name: "opencv4",
    include_paths: [
        "/usr/include/opencv4",
    ],
    version: "4.3.0",
    cargo_metadata: [
        "cargo:rustc-link-search=native=/usr/lib",
        "cargo:rustc-link-lib=opencv_gapi",
        "cargo:rustc-link-lib=opencv_stitching",
        "cargo:rustc-link-lib=opencv_alphamat",
        "cargo:rustc-link-lib=opencv_aruco",
        "cargo:rustc-link-lib=opencv_bgsegm",
        "cargo:rustc-link-lib=opencv_bioinspired",
        "cargo:rustc-link-lib=opencv_ccalib",
        "cargo:rustc-link-lib=opencv_cvv",
        "cargo:rustc-link-lib=opencv_dnn_objdetect",
        "cargo:rustc-link-lib=opencv_dnn_superres",
        "cargo:rustc-link-lib=opencv_dpm",
        "cargo:rustc-link-lib=opencv_highgui",
        "cargo:rustc-link-lib=opencv_face",
        "cargo:rustc-link-lib=opencv_freetype",
        "cargo:rustc-link-lib=opencv_fuzzy",
        "cargo:rustc-link-lib=opencv_hdf",
        "cargo:rustc-link-lib=opencv_hfs",
        "cargo:rustc-link-lib=opencv_img_hash",
        "cargo:rustc-link-lib=opencv_intensity_transform",
        "cargo:rustc-link-lib=opencv_line_descriptor",
        "cargo:rustc-link-lib=opencv_quality",
        "cargo:rustc-link-lib=opencv_rapid",
        "cargo:rustc-link-lib=opencv_reg",
        "cargo:rustc-link-lib=opencv_rgbd",
        "cargo:rustc-link-lib=opencv_saliency",
        "cargo:rustc-link-lib=opencv_stereo",
        "cargo:rustc-link-lib=opencv_structured_light",
        "cargo:rustc-link-lib=opencv_phase_unwrapping",
        "cargo:rustc-link-lib=opencv_superres",
        "cargo:rustc-link-lib=opencv_optflow",
        "cargo:rustc-link-lib=opencv_surface_matching",
        "cargo:rustc-link-lib=opencv_tracking",
        "cargo:rustc-link-lib=opencv_datasets",
        "cargo:rustc-link-lib=opencv_text",
        "cargo:rustc-link-lib=opencv_dnn",
        "cargo:rustc-link-lib=opencv_plot",
        "cargo:rustc-link-lib=opencv_videostab",
        "cargo:rustc-link-lib=opencv_videoio",
        "cargo:rustc-link-lib=opencv_viz",
        "cargo:rustc-link-lib=opencv_xfeatures2d",
        "cargo:rustc-link-lib=opencv_shape",
        "cargo:rustc-link-lib=opencv_ml",
        "cargo:rustc-link-lib=opencv_ximgproc",
        "cargo:rustc-link-lib=opencv_video",
        "cargo:rustc-link-lib=opencv_xobjdetect",
        "cargo:rustc-link-lib=opencv_objdetect",
        "cargo:rustc-link-lib=opencv_calib3d",
        "cargo:rustc-link-lib=opencv_imgcodecs",
        "cargo:rustc-link-lib=opencv_features2d",
        "cargo:rustc-link-lib=opencv_flann",
        "cargo:rustc-link-lib=opencv_xphoto",
        "cargo:rustc-link-lib=opencv_photo",
        "cargo:rustc-link-lib=opencv_imgproc",
        "cargo:rustc-link-lib=opencv_core",
    ],
}
=== Found OpenCV library version: 4.3.0 in headers located at: /home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4


error occurred: Command "sccache" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/src_cpp" "-I" "/home/horky/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.34.0/headers/4" "-I" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out" "-I" "." "-Wall" "-Wextra" "-std=c++11" "-o" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/alphamat.o" "-c" "/home/horky/Documents/WorkspaceRust/cvwasm/target/wasm32-unknown-unknown/release/build/opencv-18a6d2821fe7f5f3/out/alphamat.cpp" with args "clang" did not execute successfully (status code exit code: 1).

Horki avatar May 04 '20 20:05 Horki

I see. Well, the current build process is targeted at using OpenCV as a native shared library which is not supported in wasm environment obviously. I do have plans to explore this direction though and any help is greatly appreciated!

twistedfall avatar May 04 '20 20:05 twistedfall

I have a simple example of how to build OpenCV into Emscripten target, but still not sure how to "glue" it properly with "rustc".

https://github.com/Horki/lanelines_wasm_emscripten/blob/master/BUILD.md

Horki avatar May 04 '20 21:05 Horki

Hi @Horki @twistedfall I am also insterested in this topic. I have a bit of experience with Emscripten, and yes probably is required to link the OpenCV static libs compiled with Emscripten in the final stage of the project. I would try to dig into this, but i feel as an absolute beginner (almost) with Rust. 😢

kalwalt avatar Jan 22 '21 17:01 kalwalt

Hi, well, this task is up for grabs if you feel like it. I've done a preliminary investigation and it's not an easy deal. You would need to have some javascript glue to link wasm from opencv crate with wasm from OpenCV lib. Then there is also question of mapping the data structs between them. It's a good investigative task, but not something you would do in a week.

twistedfall avatar Jan 28 '21 10:01 twistedfall

@twistedfall does problem solved? I tried to build my app with wasm-pack and have similar errors

xyz27900 avatar Feb 15 '21 00:02 xyz27900

Nope, no real work has been done in that direction yet as far as I know.

twistedfall avatar Feb 15 '21 08:02 twistedfall

Hi, well, this task is up for grabs if you feel like it. I've done a preliminary investigation and it's not an easy deal. You would need to have some javascript glue to link wasm from opencv crate with wasm from OpenCV lib. Then there is also question of mapping the data structs between them. It's a good investigative task, but not something you would do in a week.

Hi @twistedfall back on this. Have you a reference example for this? Not with opencv-rust but another project that used the approach you explained. Thank you.

kalwalt avatar Mar 15 '21 23:03 kalwalt

Not really, I don’t think something like this has ever been done to be honest.

twistedfall avatar Mar 16 '21 06:03 twistedfall

Alternatively it may be possible to build OpenCV as static wasm and link it directly to the Rust wasm binary. As far as I know this will imply going around the standard OpenCV wasm build procedure and writing your own build script.

twistedfall avatar Mar 16 '21 06:03 twistedfall

Alternatively it may be possible to build OpenCV as static wasm and link it directly to the Rust wasm binary. As far as I know this will imply going around the standard OpenCV wasm build procedure and writing your own build script.

i did already for wasm-ar project by @EdwardLu2018 see this build script https://github.com/webarkit/opencv-em it build the opencv static libs with WASM emscripten. But how can i link the static libs in Rust?

kalwalt avatar Mar 16 '21 13:03 kalwalt

That's a good start, I didn't realize it existed! It might be way simpler to go this way. For now I'm not sure how do you statically link another wasm library. There are some hits on google like https://users.rust-lang.org/t/how-to-static-link-c-lib-to-wasm/36558 so it seems to be doable.

twistedfall avatar Mar 16 '21 13:03 twistedfall

That article is a good example i think, I will try a similar approach. Thank you @twistedfall !

kalwalt avatar Mar 16 '21 15:03 kalwalt

I would prefer to keep it open as a todo item if you don’t mind

twistedfall avatar Mar 17 '21 19:03 twistedfall

Would be nice to have wasm target added

h4x3rotab avatar Aug 03 '22 06:08 h4x3rotab

Is there any work being done for this? It seems to compile fine but the linker fails

ChillSheep avatar Jul 18 '23 21:07 ChillSheep

Not at the moment unfortunately. Linking is the main problem indeed.

twistedfall avatar Jul 19 '23 06:07 twistedfall