Linking error on Windows 10
Hello, I am trying to use OpenCV compiled from source. I already have the OpenCV built manually working for me both in C++ and Python. But when using in rust I get linking errors. I have setup all required environment variables and have no idea why this issue is arising. Information needed for are as follows:
- Windows 10
- The way you installed OpenCV: Compiled latest version from source with contrib and GPU support
- OpenCV version = 4.6.0
- rustc version (
rustc --version) = "rustc 1.63.0 (4b91a6ea7 2022-08-08)" - Attach the full output of the following command from your project directory: linking_error.txt
Sounds like img_hash module is not built in the opencv_world460.dll, but is present in the headers in E:\Libraries\C++\opencv_gpu\opencv_build\install\include. Are the headers matching with the library being used? As a workaround you can try disable the img_hash feature if you're not using it so that this module is not build.
I faced the same linking issue. I compiled opencv with contrib with visual c++ 2022. LLVM ver 14 opencv 4.6 i disabled img_hash feature but the linking still generated the same errors. link_error.txt
Can you please post the full output of cargo build -vv after doing a cargo clean?
Found the problem. img_hash was not built into opencv_world460.lib. It was built separately as opencv_img_hash460.lib. Therefore, to link properly, we had to add opencv_img_hash460.lib to OPENCV_LINK_LIBS.
OPENCV_LINK_LIBS = opencv_world460,opencv_img_hash460
the bindings worked fine after i included the img_hash lib.
Great find! I'll update the troubleshooting guide