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

multiple definition of ocvrs_create_string #597

Closed
wilwade opened this issue Jul 31, 2024 · 12 comments
Closed

multiple definition of ocvrs_create_string #597

wilwade opened this issue Jul 31, 2024 · 12 comments

Comments

@wilwade
Copy link

wilwade commented Jul 31, 2024

Running into an issue with opencv that I haven't seen anywhere else.

  • OS: clean Github Action Runner on Ubuntu Latest (Note this compiles fine on my M1 Mac)
  • Rust: Stable v1.80.0
 = note: /usr/bin/ld: /home/runner/work/metadata-portal/metadata-portal/target/debug/deps/libopencv-1885957c5723ab99.rlib(opencv-1885957c5723ab99.opencv.b72e93c0dd09b42b-cgu.1.rcgu.o): in function `ocvrs_create_string':
          /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.92.1/src/templ.rs:114: multiple definition of `ocvrs_create_string'; /home/runner/work/metadata-portal/metadata-portal/target/debug/deps/libopencv-1036cca749d0c639.rlib(opencv-1036cca749d0c639.opencv.3be91388ef299701-cgu.0.rcgu.o):/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.9/src/templ.rs:114: first defined here
          /usr/bin/ld: /home/runner/work/metadata-portal/metadata-portal/target/debug/deps/libopencv-1885957c5723ab99.rlib(opencv-1885957c5723ab99.opencv.b72e93c0dd09b42b-cgu.1.rcgu.o): in function `ocvrs_create_byte_string':
          /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.92.1/src/templ.rs:121: multiple definition of `ocvrs_create_byte_string'; /home/runner/work/metadata-portal/metadata-portal/target/debug/deps/libopencv-1036cca749d0c639.rlib(opencv-1036cca749d0c639.opencv.3be91388ef299701-cgu.0.rcgu.o):/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.9/src/templ.rs:121: first defined here
          collect2: error: ld returned 1 exit status

Perhaps I am just missing something basic, but the workflow is doing apt install -y clang libclang-dev libopencv-dev

@twistedfall
Copy link
Owner

There is 2 different version of opencv in your dependency tree:

2024-07-31T12:40:06.4812650Z   Downloaded opencv v0.92.1
2024-07-31T12:40:06.5743422Z   Downloaded opencv v0.88.9

and apparently that doesn't work, which is logical when I think about it. So the solution would be to make sure there is only a single opencv version. As far as I can see the version 0.92 is the direct dep, but 0.88 seems to be a transitive dependency.

@wilwade
Copy link
Author

wilwade commented Jul 31, 2024

Ah that does make sense. I missed that looking through everything.

Thanks. I switched to use only 0.88.9 and that fixed it. Not sure why I didn't get the same error on Mac, but working and knowing why is 💯.

@wilwade wilwade closed this as completed Jul 31, 2024
@twistedfall
Copy link
Owner

On the other hand it's actually a bug and it looks like it's easy to fix, can you please try to use v0.92.2 to see if the error is fixed in your case?

@twistedfall twistedfall reopened this Aug 1, 2024
@twistedfall
Copy link
Owner

You should also not need this lints section in your Cargo.toml anymore:

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
  'cfg(ocvrs_opencv_branch_32)',
] }

@wilwade
Copy link
Author

wilwade commented Aug 1, 2024

Testing out now... frequency-chain/metadata-portal#87

@wilwade
Copy link
Author

wilwade commented Aug 1, 2024

You should also not need this lints section in your Cargo.toml anymore:

That still error'd on me:

error: unexpected `cfg` condition name: `ocvrs_opencv_branch_32`
  --> cli/src/common/camera.rs:55:15
   |
55 |     #[cfg(not(ocvrs_opencv_branch_32))]
   |               ^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ocvrs_opencv_branch_32)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(ocvrs_opencv_branch_32)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
   = note: `-D unexpected-cfgs` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]`

https://github.com/frequency-chain/metadata-portal/actions/runs/10202774937/job/28227646901

Testing again with keeping the [lints.rust]: https://github.com/frequency-chain/metadata-portal/actions/runs/10202867537/job/28227926403?pr=87

@twistedfall
Copy link
Owner

I see, I’ll need to check why the lints are still needed

@wilwade
Copy link
Author

wilwade commented Aug 1, 2024

Nope. Same error: https://github.com/frequency-chain/metadata-portal/actions/runs/10202867537/job/28227926403?pr=87

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcNOJAnL/symbols.o" "/home/runner/work/metadata-portal/metadata-portal/target/debug/deps/metadata_cli-7b11c7f58e480db9.metadata_cli.49bc5debc42862cd-cgu.00.rcgu.o" "/home/runner/work/metadata-portal/metadata-portal/target/debug/deps/metadata_cli-7b11c7f58e480db9.metadata_cli.49bc5debc42862cd-cgu.01.rcgu.o" "/home/runner/work/metadata-portal/metadata-portal/target/debug/deps/metadata
  = note: /usr/bin/ld: /home/runner/work/metadata-portal/metadata-portal/target/debug/deps/libopencv-51c564336398a82f.rlib(opencv-51c564336398a82f.opencv.c24af44cca3222fd-cgu.1.rcgu.o): in function `ocvrs_create_string':
          /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.92.2/src/templ.rs:114: multiple definition of `ocvrs_create_string'; /home/runner/work/metadata-portal/metadata-portal/target/debug/deps/libopencv-1036cca749d0c639.rlib(opencv-1036cca749d0c639.opencv.3be91388ef299701-cgu.0.rcgu.o):/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.9/src/templ.rs:114: first defined here
          /usr/bin/ld: /home/runner/work/metadata-portal/metadata-portal/target/debug/deps/libopencv-51c564336398a82f.rlib(opencv-51c564336398a82f.opencv.c24af44cca3222fd-cgu.1.rcgu.o): in function `ocvrs_create_byte_string':
          /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.92.2/src/templ.rs:121: multiple definition of `ocvrs_create_byte_string'; /home/runner/work/metadata-portal/metadata-portal/target/debug/deps/libopencv-1036cca749d0c639.rlib(opencv-1036cca749d0c639.opencv.3be91388ef299701-cgu.0.rcgu.o):/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.9/src/templ.rs:121: first defined here
          collect2: error: ld returned 1 exit status

@twistedfall
Copy link
Owner

Thanks for checking! I’ll try to see why it didn’t work for you

@twistedfall
Copy link
Owner

twistedfall commented Sep 22, 2024

This should now be fixed as long as one of the used versions is 0.93.1, can you please check to confirm?

@wilwade
Copy link
Author

wilwade commented Sep 23, 2024

I had to keep the lint line in, but it is now working! Thanks for the fix!

https://github.com/frequency-chain/metadata-portal

Retained Lint:

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
  'cfg(ocvrs_opencv_branch_32)',
] }

@wilwade wilwade closed this as completed Sep 23, 2024
@twistedfall
Copy link
Owner

Yeah, I think that the lint warnings are triggered by the older version of the crate

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