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

Compilation issues on cross zigbuild

Open DennisZhangOiler opened this issue 1 year ago • 2 comments

  1. Operating system Host Ubuntu 22.04 Cross v0.2.5 aarch64-unknown-linux-gnu zigbuild 0.17.5 target glibc version 2.27

  2. The way you installed OpenCV: package, official binary distribution, manual compilation, etc. Manual compilation from cmake, then setup CMAKE_PREFIX_PATH

  3. OpenCV version 4.1.1

  4. rustc version (rustc --version) rustc 1.77.0 (aedd173a2 2024-03-17)

  5. Attach the full output of the following command from your project directory:

cross build --target aarch64-unknown-linux-gnu
  = note: ld.lld: error: undefined symbol: cv::imwrite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, cv::_InputArray const&, std::__1::vector<int, std::__1::allocator<int>> const&)
          >>> referenced by imgcodecs.cpp:85 (/target/aarch64-unknown-linux-gnu/debug/build/opencv-415f844eed75b8c0/out/imgcodecs.cpp:85)
          >>>               15890d46206e65af-imgcodecs.o:(cv_imwrite_const_StringR_const__InputArrayR_const_vectorLintGR) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-1756b9ba42e7ca3d.rlib

          ld.lld: error: undefined symbol: cv::error(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const*, char const*, int)
          >>> referenced by mat.inl.hpp:548 (/opencv/platforms/linux/build/install/include/opencv4/opencv2/core/mat.inl.hpp:548)
          >>>               15890d46206e65af-core.o:(cv::Mat::Mat(int, int, int, void*, unsigned long)) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-1756b9ba42e7ca3d.rlib
          >>> referenced by mat.inl.hpp:558 (/opencv/platforms/linux/build/install/include/opencv4/opencv2/core/mat.inl.hpp:558)
          >>>               15890d46206e65af-core.o:(cv::Mat::Mat(int, int, int, void*, unsigned long)) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-1756b9ba42e7ca3d.rlib
          >>> referenced by mat.inl.hpp:561 (/opencv/platforms/linux/build/install/include/opencv4/opencv2/core/mat.inl.hpp:561)
          >>>               15890d46206e65af-core.o:(cv::Mat::Mat(int, int, int, void*, unsigned long)) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-1756b9ba42e7ca3d.rlib
          >>> referenced 6 more times

DennisZhangOiler avatar Apr 30 '24 03:04 DennisZhangOiler

I would first suggest you try newest OpenCV version: 4.9.0, the one you use, 4.1.1, is very old. If it still fails, please attach the full build log as produced by cargo build -vv after doing a cargo clean.

twistedfall avatar May 08 '24 06:05 twistedfall

I would first suggest you try newest OpenCV version: 4.9.0, the one you use, 4.1.1, is very old. If it still fails, please attach the full build log as produced by cargo build -vv after doing a cargo clean.

Hi @twistedfall , it's probably due to upstream zig problem, that zig does not work with dual ABI, you can check it from here and here, I am still looking for solutions that can build opencv with clang++ or cargo zigbuild add some link flags, thank you for replying!

DennisZhangOiler avatar May 08 '24 07:05 DennisZhangOiler

I hope that you found the solution by now, I'm going to close this issue, but if you still need support please feel free to reopen.

twistedfall avatar Nov 12 '24 14:11 twistedfall