ccouzens / tesseract-sys

Rust FFI bindings to tesseract
MIT License
26 stars 18 forks source link

Error compiling on Gentoo #13

Closed ccouzens closed 2 years ago

ccouzens commented 2 years ago

I'm moving the 2nd half of this issue to this repository https://github.com/houqp/leptess/issues/25#issuecomment-1019886107

Tesseract-sys isn't picking up the constant kMaxCredibleResolution on the user's system.

ccouzens commented 2 years ago

I spent some time the other evening trying to reproduce using a Gentoo container. It was slow going having to compile everything, and I've not used Gentoo in about 15 years.

Here are my notes:

docker container run --rm -it docker.io/gentoo/stage3
emaint -a sync

emerge dev-vcs/git app-text/tesseract sys-devel/clang llvm sys-devel/gcc

git clone https://github.com/ccouzens/tesseract-sys.git

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

source $HOME/.cargo/env

cd tesseract-sys

LIBCLANG_PATH=/usr/lib/llvm/13/lib64/libclang.so cargo build
#   /usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found :(
houqp commented 2 years ago

Based on https://github.com/houqp/leptess/issues/25#issuecomment-1024627944, it looks like tesseract might have removed the symbol in 5.x? Are you able to see it defined in gentoo's header files?

ccouzens commented 2 years ago

Are you able to see it defined in gentoo's header files?

I am, but my steps have installed 4.1.1

3199c8695613 /tesseract-sys # tesseract --version
tesseract 4.1.1

Hey @wiredhikari , what did you do to install tesseract 5 on Gentoo?

wiredhikari commented 2 years ago

Hello,there are several ways. You can run the following command

echo >app-text/tesseract-5.0.0 >> /etc/portage/package.mask

and then run

sudo emerge tesseract

gokberkkocak commented 2 years ago

Hi,

I don't think this issue is limited Gentoo only. I'm having the same problem on Arch Linux with Tesseract 5.0.1 and leptonica 1.82 installed.

Package info:

gk@DELL-XPS ~/.d/r/repo $ pacman -Qs tesseract                                                                                                                                                      main
local/tesseract 5.0.1-2
    An OCR program
local/tesseract-data-eng 2:4.1.0-2 (tesseract-data)
    Tesseract OCR data (eng)
gk@DELL-XPS ~/.d/r/repo $ pacman -Qs leptonica                                                                                                                                                         main
local/leptonica 1.82.0-1
    Software that is broadly useful for image processing and image analysis applications

Error

error[E0432]: unresolved import `capi::kMaxCredibleResolution`
 --> /home/gk/.cargo/registry/src/github.com-1ecc6299db9ec823/leptess-0.13.2/src/tesseract.rs:9:9
  |
9 | pub use capi::kMaxCredibleResolution as MAX_CREDIBLE_RESOLUTION;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `kMaxCredibleResolution` in `capi`

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

For more information about this error, try `rustc --explain E0432`.
error: could not compile `leptess` due to 2 previous errors

kMaxCredibleResolution and kMinCredibleResolution do exist in the system.

gk@DELL-XPS ~/.d/r/repo $ grep -r kMaxCredibleResolution /usr/include/tesseract/                                                                                                                    main
/usr/include/tesseract/publictypes.h:constexpr int kMaxCredibleResolution = 2400;
gk@DELL-XPS ~/.d/r/repo $ grep -r kMinCredibleResolution /usr/include/tesseract/                                                                                                                       main
/usr/include/tesseract/publictypes.h:constexpr int kMinCredibleResolution = 70;
ccouzens commented 2 years ago

I believe this PR should fix this https://github.com/ccouzens/tesseract-sys/pull/15