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

error[E0425]: cannot find value QuantumRange in module bindings #40

Closed
bbigras opened this issue May 15, 2018 · 10 comments
Closed

error[E0425]: cannot find value QuantumRange in module bindings #40

bbigras opened this issue May 15, 2018 · 10 comments

Comments

@bbigras
Copy link
Contributor

bbigras commented May 15, 2018

I have this error with magick-rust 0.9. 0.8 seems fine.

Windows
ImageMagick-7.0.7-31
nightly-x86_64-pc-windows-msvc (default)
rustc 1.27.0-nightly (428ea5f6b 2018-05-06)

error[E0425]: cannot find value `QuantumRange` in module `bindings`
   --> C:\Users\bbigras\.cargo\registry\src\github.com-1ecc6299db9ec823\magick_rust-0.9.0\src\wand\magick.rs:337:80
    |
337 |             if bindings::MagickSepiaToneImage(self.wand, threshold * bindings::QuantumRange) == bindings::MagickBooleanType::MagickTrue {
    |
     ^^^^^^^^^^^^ not found in `bindings`

error: aborting due to previous error
@nlfiedler
Copy link
Owner

The generated bindings can be quite troublesome, I have to admit. I don't have a Windows system to test this, but that may not be the issue. If I can get a Windows VM to test with, I'll give it a try. In the mean time, look for the bindings.rs file and see how QuantumRange is namespaced. Maybe it's getting some additional prefix, as bindgen has a tendency to do different things depending on flags and versions.

@bbigras
Copy link
Contributor Author

bbigras commented May 17, 2018

There's no QuantumRange "whole word" in bindings.rs, The only matches are:

extern "C" {
    pub fn GetMagickQuantumRange(arg1: *mut usize) -> *const libc::c_char;
}
extern "C" {
    pub fn MagickGetQuantumRange(arg1: *mut usize) -> *const libc::c_char;
}

@vpzomtrrfrt
Copy link

I'm seeing the same issue on my Gentoo system.

@gentoo90
Copy link
Contributor

gentoo90 commented Dec 6, 2018

Seing the same error with magick_rust-0.10.0.

Gentoo Linux,
rustc 1.32.0-nightly (14997d56a 2018-12-05),
imagemagick-7.0.8.11,
clang-6.0.1,
bindgen-0.29.1

@WGH-
Copy link

WGH- commented May 2, 2019

Still happens as of v0.11.0. I'm on Gentoo as well.

@captainbland
Copy link
Contributor

captainbland commented Jun 6, 2020

Sorry to exhume this but maybe it'll be helpful: I've come across this error now using Ubuntu 18.04. What happened was I was using a quantum depth of 16 before and the build worked, everything was happy, but I was having some performance issues so I tried re-building ImageMagick with a quantum depth of 8 and hdri disabled, and now I'm getting the "QuantumRange not found in bindings" error when I try to clean/build my application.

This is with ImageMagick 7.0.10-16 and magick_rust 0.14.0, rust 0.45.0-nightly

@nlfiedler
Copy link
Owner

I see, that would certainly explain why some people see it and others do not. I wish I knew how to deal with this in better way.

@captainbland
Copy link
Contributor

captainbland commented Jun 8, 2020

After a little digging I think the problem with this is to do with this issue:
rust-lang/rust-bindgen#1585
rust-lang/rust-bindgen#316

You can see a similar cast/define being performed where HDRI is disabled in magick-type.h when defining the QuantumRange type (indentation editorialised somewhat here)

#if (MAGICKCORE_QUANTUM_DEPTH == 8)
  #define MaxColormapSize  256UL
  #define MaxMap  255UL

  #if defined(MAGICKCORE_HDRI_SUPPORT)
    typedef MagickFloatType Quantum;
    #define QuantumRange  255.0
    #define QuantumFormat  "%g"
  #else
    typedef unsigned char Quantum;
    #define QuantumRange  ((Quantum) 255)
    #define QuantumFormat  "%u"
#endif

So I'm just recompiling with quantum size=8 and hdri enabled which, if I'm correct, should give me the QuantumRange type in this library. I'll update here when I've tested it.

Edit: it works

@MolotovCherry
Copy link

MolotovCherry commented Sep 21, 2021

Had this issue randomly, the patch giving features = ["disable-hdri"] did allow it to compile for me (so thanks for that). Could this be added to the main page for documentation purposes?

Also, MAGICKCORE_HDRI_ENABLE is set accordingly in the bindings. Perhaps it is possible to check and set things according to the value of this.

@nlfiedler
Copy link
Owner

Sorry it took me a long time to respond to this. I've updated the README file so that this issue is easier resolve, at least with this temporary work-around. Eventually the issue in rust-bindgen will be fixed, and setting the feature flag in your application won't be necessary any more.

I think for now this issue can be closed, since there is a work-around and finally some guidance in the README file.

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

7 participants