cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.79k stars 379 forks source link

zig build undefined symbols on ld linking #1486

Open DennisZhangOiler opened 6 months ago

DennisZhangOiler commented 6 months ago

Checklist

Describe your issue

My rust program with opencv-rs builds fine without zig glibc version assigned. But when I built with zig, no matter what version I am using, it missed the libraries should be linked in.

  = 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-bb13004260793875/out/imgcodecs.cpp:85)
          >>>               0de9285bc4b8b0c1-imgcodecs.o:(cv_imwrite_const_StringR_const__InputArrayR_const_vectorLintGR) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-761bbc32057b17de.rlib

          ld.lld: error: undefined symbol: cv::format(char const*, ...)
          >>> referenced by dnn.inl.hpp:297 (/opencv/platforms/linux/build/install/include/opencv4/opencv2/dnn/dnn.inl.hpp:297)
          >>>               0de9285bc4b8b0c1-dnn.o:(cv::dnn::dnn4_v20190621::DictValue::size() const) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-761bbc32057b17de.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 dnn.inl.hpp:297 (/opencv/platforms/linux/build/install/include/opencv4/opencv2/dnn/dnn.inl.hpp:297)
          >>>               0de9285bc4b8b0c1-dnn.o:(cv::dnn::dnn4_v20190621::DictValue::size() const) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-761bbc32057b17de.rlib
          >>> referenced by mat.inl.hpp:548 (/opencv/platforms/linux/build/install/include/opencv4/opencv2/core/mat.inl.hpp:548)
          >>>               0de9285bc4b8b0c1-core.o:(cv::Mat::Mat(int, int, int, void*, unsigned long)) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-761bbc32057b17de.rlib
          >>> referenced by mat.inl.hpp:558 (/opencv/platforms/linux/build/install/include/opencv4/opencv2/core/mat.inl.hpp:558)
          >>>               0de9285bc4b8b0c1-core.o:(cv::Mat::Mat(int, int, int, void*, unsigned long)) in archive /target/aarch64-unknown-linux-gnu/debug/deps/libopencv-761bbc32057b17de.rlib
          >>> referenced 7 more times

What target(s) are you cross-compiling for?

aarch64-unknown-linux-gnu

Which operating system is the host (e.g computer cross is on) running?

What architecture is the host?

What container engine is cross using?

cross version

cross 0.2.5 (7a2b4e4 2024-04-29)

Example

No response

Additional information / notes

No response

Emilgardis commented 6 months ago

This is a know limitation, I don't know how to cross-compile with zig cc + external symbols for a nonnative target

DennisZhangOiler commented 6 months ago

This is a know limitation, I don't know how to cross-compile with zig cc + external symbols for a nonnative target

I think it's probably due to unknown linking path or wrong environment variables, those are properly set in gcc.

DennisZhangOiler commented 6 months ago

I am not sure if this post can solve the problem.