houqp / leptess

Productive and safe Rust binding for leptonica and tesseract
https://houqp.github.io/leptess/leptess/index.html
MIT License
258 stars 28 forks source link

Unresolved import issue #25

Closed Gvstavo closed 3 years ago

Gvstavo commented 3 years ago

I can't compile

Compiling leptess v0.9.0
error[E0432]: unresolved import `capi::kMaxCredibleResolution`
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/leptess-0.9.0/src/tesseract.rs:10:9
   |
10 | pub use capi::kMaxCredibleResolution as MAX_CREDIBLE_RESOLUTION;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `kMaxCredibleResolution` in `capi`

error[E0432]: unresolved import `capi::kMinCredibleResolution`
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/leptess-0.9.0/src/tesseract.rs:11:9
   |
11 | pub use capi::kMinCredibleResolution as MIN_CREDIBLE_RESOLUTION;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `kMinCredibleResolution` in `capi`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0432`.
error: could not compile `leptess`.

My Cargo.toml

leptess = "*"

tesseract --version output

tesseract 3.04.01
 leptonica-1.74.1
  libgif 5.1.4 : libjpeg 6b (libjpeg-turbo 1.5.1) : libpng 1.6.28 : libtiff 4.0.8 : zlib 1.2.8 : libwebp 0.5.2 : libopenjp2 2.1.2

Rust version: 1.47.0 (18bf6b4f0 2020-10-07) OS: Debian stretch

ccouzens commented 3 years ago

Hi @Gvstavo ,

I suspect the issue is that kMaxCredibleResolution isn't in your tesseract c headers.

On my fedora laptop, I can see that it's defined here:

grep -r kMaxCredibleResolution /usr/include/tesseract/
/usr/include/tesseract/publictypes.h:constexpr int kMaxCredibleResolution = 2400;

I'll investigate using a debian stretch container

ccouzens commented 3 years ago

My Debian stretch container with libtesseract-dev didn't have it either.

The constant has been defined for 3 years (since Tesseract 4.0.0).

Debian stretch is using version 3.04.01-5 which was released over 4 years ago.

As far as I know, it isn't practical in rust to conditionally compile based on if other libraries define a value.

Is it possible to compile a more up to date version of Tesseract on your computer?

houqp commented 3 years ago

perhaps we should add a note that we only support 4.0.0 onward. i don't see much value putting work into support a library version that's more than 4 years old :)

Gvstavo commented 3 years ago

Thanks for the help, I try to compile in a machine with Debian 10 and Tesseract 4.0 and it works.

wiredhikari commented 2 years ago

I am getting the same issue on Gentoo Linux even after having tesseract 5.0.1 and leptonica-1.82.0, also I get this output grep -r kMaxCredibleResolution /usr/include/tesseract/ /usr/include/tesseract/publictypes.h:constexpr int kMaxCredibleResolution = 2400;. How shall I fix this?

ccouzens commented 2 years ago

Could you please run this for me and paste the output here?

pkg-config --path tesseract
cat "$(pkg-config --path tesseract)"

Back in December we switched to using pkg-config to determine the include paths on Linux https://github.com/ccouzens/tesseract-sys/pull/10/

I want to see if your tesseract pkg-config file is much different to mine.

I'm not very familiar with how C header imports work, but in this case I think we need to verify your pkg-config file contains the line includedir=/usr/include.

wiredhikari commented 2 years ago

image I am getting these outputs

ccouzens commented 2 years ago

Hey @wiredhikari ,

I'm moving this issue here: https://github.com/ccouzens/tesseract-sys/issues/13

tesseract-sys is used by leptess. It's where we read in the constant kMaxCredibleResolution.

wiredhikari commented 2 years ago

I have been tinkering with the versions of tesseract and found that the later version 5.0.0 caused this error while 4.1.1 worked fine.

Somepub commented 1 year ago

I have same issue on Windows 10, runs fine on Linux. I tried to follow this thread, but no result. https://github.com/houqp/leptess/issues/3#issuecomment-578556818 As I understand Leptess cant find Leptonica headers what lies on include\leptonica I also tried set LEPTONICA_INCLUDE_PATH=... set LEPTONICA_LINK_PATHS=... set LEPTONICA_LINK_LIBS=leptonica-1.83.0 I'm not use to Windows environment, so I'm sorry if I missed something.