axinc-ai / ailia-models-rust

3 stars 0 forks source link

OpenCV build error on macOS #3

Closed kyakuno closed 4 months ago

kyakuno commented 4 months ago

OpenCVのビルドエラーが発生する。

error[E0425]: cannot find function `mul_matexpr_mat` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:153:11
    |
153 | impl_ops!(mul_matexpr_mat, Mul, MatExpr, Mat, mul);
    |           ^^^^^^^^^^^^^^^ help: a function with a similar name exists: `elemmul_matexpr_mat`
...
177 | fn elemmul_matexpr_mat(a: &MatExpr, b: &Mat) -> Result<MatExpr> {
    | --------------------------------------------------------------- similarly named function `elemmul_matexpr_mat` defined here

error[E0425]: cannot find function `mul_matexpr_matexpr` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:154:11
    |
154 | impl_ops!(mul_matexpr_matexpr, Mul, MatExpr, MatExpr, mul);
    |           ^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `elemmul_matexpr_matexpr`
...
180 | fn elemmul_matexpr_matexpr(a: &MatExpr, b: &MatExpr) -> Result<MatExpr> {
    | ----------------------------------------------------------------------- similarly named function `elemmul_matexpr_matexpr` defined here

error[E0425]: cannot find function `mul_mat_f64` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:156:11
    |
156 | impl_ops!(mul_mat_f64, Mul, Mat, f64, mul);
    |           ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `mul_matexpr_f64` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:157:11
    |
157 | impl_ops!(mul_matexpr_f64, Mul, MatExpr, f64, mul);
    |           ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `mul_f64_mat` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:158:11
    |
158 | impl_ops!(mul_f64_mat, Mul, f64, Mat, mul);
    |           ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `mul_f64_matexpr` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:159:11
    |
159 | impl_ops!(mul_f64_matexpr, Mul, f64, MatExpr, mul);
    |           ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `div_mat_mat` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:161:11
    |
161 | impl_ops!(div_mat_mat, Div, Mat, Mat, div);
    |           ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `div_mat_matexpr` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:162:11
    |
162 | impl_ops!(div_mat_matexpr, Div, Mat, MatExpr, div);
    |           ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `div_matexpr_mat` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:163:11
    |
163 | impl_ops!(div_matexpr_mat, Div, MatExpr, Mat, div);
    |           ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `div_matexpr_matexpr` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:164:11
    |
164 | impl_ops!(div_matexpr_matexpr, Div, MatExpr, MatExpr, div);
    |           ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `div_mat_f64` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:166:11
    |
166 | impl_ops!(div_mat_f64, Div, Mat, f64, div);
    |           ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `div_matexpr_f64` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:167:11
    |
167 | impl_ops!(div_matexpr_f64, Div, MatExpr, f64, div);
    |           ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `div_f64_mat` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:168:11
    |
168 | impl_ops!(div_f64_mat, Div, f64, Mat, div);
    |           ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `div_f64_matexpr` in this scope
   --> /Users/kyakuno/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.76.4/src/manual/core/mat_ops.rs:169:11
    |
169 | impl_ops!(div_f64_matexpr, Div, f64, MatExpr, div);
    |           ^^^^^^^^^^^^^^^ not found in this scope

Some errors have detailed explanations: E0405, E0412, E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0405`.
The following warnings were emitted during compilation:

warning: In file included from /Users/kyakuno/Desktop/ailia/ailia-models-rust/detic/target/release/build/opencv-70d5caffc9e252fd/out/saliency.cpp:2:
warning: In file included from /usr/local/opt/opencv/include/opencv4/opencv2/saliency.hpp:46:
warning: /usr/local/opt/opencv/include/opencv4/opencv2/saliency/saliencySpecializedClasses.hpp:311:16: warning: 'cv::saliency::ObjectnessBING::read' hides overloaded virtual function [-Woverloaded-virtual]
warning:   CV_WRAP void read();
warning:                ^
warning: /usr/local/opt/opencv/include/opencv4/opencv2/core.hpp:3165:26: note: hidden overloaded virtual function 'cv::Algorithm::read' declared here: different number of parameters (1 vs 0)
warning:     CV_WRAP virtual void read(const FileNode& fn) { CV_UNUSED(fn); }
warning:                          ^
warning: In file included from /Users/kyakuno/Desktop/ailia/ailia-models-rust/detic/target/release/build/opencv-70d5caffc9e252fd/out/saliency.cpp:2:
warning: In file included from /usr/local/opt/opencv/include/opencv4/opencv2/saliency.hpp:46:
warning: /usr/local/opt/opencv/include/opencv4/opencv2/saliency/saliencySpecializedClasses.hpp:312:16: warning: 'cv::saliency::ObjectnessBING::write' hides overloaded virtual function [-Woverloaded-virtual]
warning:   CV_WRAP void write() const;
warning:                ^
warning: /usr/local/opt/opencv/include/opencv4/opencv2/core.hpp:3152:26: note: hidden overloaded virtual function 'cv::Algorithm::write' declared here: different number of parameters (1 vs 0)
warning:     CV_WRAP virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
warning:                          ^
warning: 2 warnings generated.
kyakuno commented 4 months ago

opencvを0.76.1から0.91.3にしてみる。 https://github.com/twistedfall/opencv-rust

kyakuno commented 4 months ago

改善しなかったので、rustをupdateすると、下記のエラー。

error: failed to run custom build command for clang-sys v1.7.0

kyakuno commented 4 months ago

brew install llvmが必要そう。

kyakuno commented 4 months ago

下記と同じでopencv 0.8.0がいるみたい。 https://github.com/axinc-ai/ailia_yolox_rust/issues/1 https://github.com/twistedfall/opencv-rust/issues/462

kyakuno commented 4 months ago

llvmを入れても、  error: failed to run custom build command for clang-sys v1.7.0 は改善せず。

kyakuno commented 4 months ago

llvmを入れて、opencv 0.80.0にすると動いた。

kyakuno commented 4 months ago

っと思ったら、libcでエラー。

  === Building binding-generator binary:
  ===    Compiling libc v0.2.139
  ===    Compiling glob v0.3.0
  ===    Compiling memchr v2.5.0
  === error: failed to run custom build command for `libc v0.2.139`
  === 
  === Caused by:
  ===   process didn't exit successfully: `/Users/kyakuno/Desktop/ailia/ailia-models-rust/detic/target/debug/build/opencv-db232869378350f7/out/release/build/libc-8f3459b16eeb531b/build-script-build` (signal: 9, SIGKILL: kill)
  === warning: build failed, waiting for other jobs to finish...
  Error: "Failed to build the bindings generator"
warning: build failed, waiting for other jobs to finish...

https://github.com/rust-lang/cargo/issues/11641

kyakuno commented 4 months ago

昔ビルドできていた、ailia_yolox_rustでも同じエラーになる。

kyakuno commented 4 months ago

opencv v0.91.3だと下記のエラーになる。 a libclang shared library is not loaded on this thread

これは下記のPoint.8である。 https://github.com/twistedfall/opencv-rust/blob/master/TROUBLESHOOTING.md

opencvのdependenciesのfeaturesにclang-runtimeを入れろと書いている。 opencv = {version = "*", features = [ "clang-runtime"]} https://qiita.com/higumachan725/items/25198370ce6b8603356e

kyakuno commented 4 months ago

opencvをv0.91.3にアップデートして、clang-runtimeを入れたらailia-sysはビルドできた。

kyakuno commented 4 months ago

アプリもビルドできた。