Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo build failing for opencv with following error: #503

Closed
deepushajia opened this issue Oct 12, 2023 · 8 comments
Closed

Cargo build failing for opencv with following error: #503

deepushajia opened this issue Oct 12, 2023 · 8 comments

Comments

@deepushajia
Copy link

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
    WINDOWS 11

  2. The way you installed OpenCV: package, official binary distribution, manual compilation, etc.
    Compilation from source using cmake and visual studio 2022

  3. OpenCV version
    4.8.0

  4. rustc version (rustc --version)
    1.60

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

    RUST_BACKTRACE=full cargo build -vv 

    libopencv-ba266e7466d1bc32.rlib(c6a52e00b2d3fa25-stitching.o) : error LNK2019: unresolved external symbol "public: enum cv::Stitcher::Status __cdecl cv::Stitcher::composePanorama(class cv::_InputArray const &,class cv::_OutputArray const &)" (?composePanorama@Stitcher@cv@@qeaa?AW4Status@12@AEBV_InputArray@2@AEBV_OutputArray@2@@z) referenced in function cv_Stitcher_composePanorama_const__InputArrayR_const__OutputArrayR
    libopencv-ba266e7466d1bc32.rlib(c6a52e00b2d3fa25-stitching.o) : error LNK2019: unresolved external symbol "public: enum cv::Stitcher::Status __cdecl cv::Stitcher::stitch(class cv::_InputArray const &,class cv::_OutputArray const &)" (?stitch@Stitcher@cv@@qeaa?AW4Status@12@AEBV_InputArray@2@AEBV_OutputArray@2@@z) referenced in function cv_Stitcher_stitch_const__InputArrayR_const__OutputArrayR
    libopencv-ba266e7466d1bc32.rlib(c6a52e00b2d3fa25-stitching.o) : error LNK2019: unresolved external symbol "public: enum cv::Stitcher::Status __cdecl cv::Stitcher::stitch(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &)" (?stitch@Stitcher@cv@@qeaa?AW4Status@12@AEBV_InputArray@2@0AEBV_OutputArray@2@@z) referenced in function cv_Stitcher_stitch_const__InputArrayR_const__InputArrayR_const__OutputArrayR
    C:\Users\dipsico\Desktop\fabritow-desktop\src-tauri\target\debug\deps\app.exe : fatal error LNK1120: 680 unresolved externals

@twistedfall
Copy link
Owner

I would be great if you you could provide the full output of the cargo build -vv after doing a cargo clean!

@deepushajia
Copy link
Author

Sure please look at this file:
build_log.txt

@twistedfall
Copy link
Owner

As far as I can see you've built a very limited set of opencv modules:

[opencv 0.85.1]         "cargo:rustc-link-lib=opencv_core",
[opencv 0.85.1]         "cargo:rustc-link-lib=opencv_imgproc",
[opencv 0.85.1]         "cargo:rustc-link-lib=opencv_highgui",
[opencv 0.85.1]         "cargo:rustc-link-lib=opencv_videoio",

I would recommend you limiting the crate module set in Cargo.toml too :

opencv ={ version = "0.85", default-features = false, features = ["imgproc", "highgui", "videoio"]}

That would skip the binding generation for the missing stiching module and you won't have linking errors.

If alternatively you do want to use the stitching module and you enabled it, then your generated pkg-config configuration might be wrong for some reason. As a workaround you could try force-adding the module manually via the following environment variable:

OPENCV_LINK_LIBS="+opencv_stitching"

@twistedfall
Copy link
Owner

Or you can also try disabling the pkg-config probe to try cmake probe instead:

OPENCV_DISABLE_PROBES="pkg_config"

@deepushajia
Copy link
Author

Thanks, setting the features alone resolved the issues for now.

@deepushajia
Copy link
Author

Although the successfully run build is returning this error on startup :
the code execution cannot proceed because opencv_code480.dll not found tauri build.

@twistedfall
Copy link
Owner

Try placing this DLL next to the binary you're running. Also please check the point 4 from the Troubleshooting guide: https://github.com/twistedfall/opencv-rust#troubleshooting

@deepushajia
Copy link
Author

Yes. This helped. Thanks a lot.
Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants