Enet4 / dicom-rs

Rust implementation of the DICOM standard
https://dicom-rs.github.io
Apache License 2.0
403 stars 75 forks source link

Version of openjp2 causing issue in new projects #501

Closed cstrickland-pag closed 2 months ago

cstrickland-pag commented 2 months ago

This is an issue I am only getting on new projects. I have the same dependencies including version in an older project that works without error. Below is a simplified set of steps that can reproduce the issue. I did notice different versions of sub-dependencies in Cargo.lock file. Specifically in older project, with the same dependency versions I get:

jpeg2k: 0.6.6 vs 0.6.7 openjpy: 0.3.0 vs 0.3.4

To replicate (running on Linux, cargo 1.76.0 ):

This creates the following dependencies in the Cargo.toml [dependencies] dicom = { version = "0.6.3", features = ["pixeldata"] }

Then run:

error[E0425]: cannot find value opj_stream_read_seek in this scope --> /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openjp2-0.3.4/src/openjpeg.rs:672:7 672 opj_stream_read_seek ^^^^^^^^^^^^^^^^^^^^ not found in this scope
help: consider importing this function 34 + use crate::cio::opj_stream_read_seek;
error[E0425]: cannot find value opj_stream_write_skip in this scope --> /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openjp2-0.3.4/src/openjpeg.rs:682:7 682 opj_stream_write_skip ^^^^^^^^^^^^^^^^^^^^^ not found in this scope
help: consider importing this function 34 + use crate::cio::opj_stream_write_skip;
error[E0425]: cannot find value opj_stream_write_seek in this scope --> /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openjp2-0.3.4/src/openjpeg.rs:690:7 690 opj_stream_write_seek ^^^^^^^^^^^^^^^^^^^^^ not found in this scope
help: consider importing this function 34 + use crate::cio::opj_stream_write_seek;
error[E0425]: cannot find value opj_stream_default_read in this scope --> /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openjp2-0.3.4/src/openjpeg.rs:699:5 699 opj_stream_default_read ^^^^^^^^^^^^^^^^^^^^^^^ ... 726 pub unsafe extern "C" fn opj_stream_default_create(mut l_is_input: OPJ_BOOL) -> *mut opj_stream_t { ------------------------------------------------------------------------------------------------- similarly named function opj_stream_default_create defined here
help: a function with a similar name exists 699 opj_stream_default_create
help: consider importing this function 34 + use crate::cio::opj_stream_default_read;
error[E0425]: cannot find value opj_stream_default_write in this scope --> /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openjp2-0.3.4/src/openjpeg.rs:707:5 707 opj_stream_default_write ^^^^^^^^^^^^^^^^^^^^^^^^ ... 726 pub unsafe extern "C" fn opj_stream_default_create(mut l_is_input: OPJ_BOOL) -> *mut opj_stream_t { ------------------------------------------------------------------------------------------------- similarly named function opj_stream_default_create defined here
help: a function with a similar name exists 707 opj_stream_default_create
help: consider importing this function 34 + use crate::cio::opj_stream_default_write;
error[E0425]: cannot find value opj_stream_default_skip in this scope --> /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openjp2-0.3.4/src/openjpeg.rs:715:5 715 opj_stream_default_skip ^^^^^^^^^^^^^^^^^^^^^^^ ... 726 pub unsafe extern "C" fn opj_stream_default_create(mut l_is_input: OPJ_BOOL) -> *mut opj_stream_t { ------------------------------------------------------------------------------------------------- similarly named function opj_stream_default_create defined here
help: a function with a similar name exists 715 opj_stream_default_create
help: consider importing this function 34 + use crate::cio::opj_stream_default_skip;
error[E0425]: cannot find value opj_stream_default_seek in this scope --> /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openjp2-0.3.4/src/openjpeg.rs:719:5 719 opj_stream_default_seek ^^^^^^^^^^^^^^^^^^^^^^^ ... 726 pub unsafe extern "C" fn opj_stream_default_create(mut l_is_input: OPJ_BOOL) -> *mut opj_stream_t { ------------------------------------------------------------------------------------------------- similarly named function opj_stream_default_create defined here
help: a function with a similar name exists 719 opj_stream_default_create
help: consider importing this function 34 + use crate::cio::opj_stream_default_seek;

For more information about this error, try rustc --explain E0425. error: could not compile openjp2 (lib) due to 8 previous errors

Please let me know if I you would like me to supply any more information on this issue? Any help on this would be greatly appreciated.

Enet4 commented 2 months ago

Thank you for reporting. This has also been brought up on our Zulip (ref). It seems that some recent patches to openjp2 broke the integration with DICOM-rs. Ideally this should be reported and patched at the 0.3.x line of openjp2.

Until then, you should be able to require exact versions which are likely not to have the problem.

[dependencies]
jpeg2k = { version = "=0.6.6", default-features = false }
openjp2 = "=0.3.1"
cstrickland-pag commented 2 months ago

Thank you for the information. By adding the additional dependencies you have suggested, I can successfully work around the issue.