| 1 | # leptonica-sys |
| 2 | |
| 3 | Rust FFI bindings to [Leptonica](http://www.leptonica.org/). |
| 4 | |
| 5 | Types and functions generated from the functions listed in |
| 6 | [allheaders.h](https://github.com/DanBloomberg/leptonica/blob/master/src/allheaders.h). |
| 7 | |
| 8 | ## Help wanted |
| 9 | |
| 10 | [Windows and Mac maintainers wanted](https://github.com/ccouzens/leptonica-sys/issues/17). |
| 11 | |
| 12 | ## Building |
| 13 | |
| 14 | This links to the C library Leptonica. |
| 15 | |
| 16 | On Fedora 30 the build dependencies can be installed by running: |
| 17 | |
| 18 | ```bash |
| 19 | sudo dnf install leptonica-devel clang |
| 20 | ``` |
| 21 | |
| 22 | On Termux 2019 (Android, Android on Chromebooks) the additional dependencies can be installed by running: |
| 23 | |
| 24 | ```bash |
| 25 | pkg install libclang leptonica-dev |
| 26 | ``` |
| 27 | |
| 28 | ### Building on Windows |
| 29 | |
| 30 | On Windows, this library uses Microsoft's [vcpkg](https://github.com/microsoft/vcpkg) to provide leptonica. |
| 31 | |
| 32 | Please install [vcpkg](https://github.com/microsoft/vcpkg) and **set up user wide integration** or [vcpkg crate](https://crates.io/crates/vcpkg) won't be able to find the library. |
| 33 | By default vcpkg installs 32 bit libraries. If you need 64 bit libraries then set following environment variable |
| 34 | |
| 35 | ```cmd |
| 36 | SET VCPKG_DEFAULT_TRIPLET=x64-windows |
| 37 | ``` |
| 38 | |
| 39 | To install leptonica |
| 40 | |
| 41 | ```cmd |
| 42 | REM from the vcpkg directory |
| 43 | .\vcpkg install leptonica |
| 44 | ``` |
| 45 | |
| 46 | vcpkg allows building either dynamically or statically linked application |
| 47 | |
| 48 | if you prefer dynamic linking |
| 49 | |
| 50 | ```cmd |
| 51 | SET VCPKGRS_DYNAMIC=true |
| 52 | ``` |
| 53 | |
| 54 | for statically linked libraries |
| 55 | |
| 56 | ```cmd |
| 57 | SET RUSTFLAGS=-Ctarget-feature=+crt-static |
| 58 | ``` |
| 59 | |
| 60 | If you prefer to compile tesseract yourself (Because, for example, you could not get vcpkg to build using clang-cl.exe), you can set these environment variables: `LEPTONICA_INCLUDE_PATH`, `LEPTONICA_LINK_PATHS` and `LEPTONICA_LINK_LIBS`. |
| 61 | |
| 62 | For example: |
| 63 | |
| 64 | ``` |
| 65 | set LEPTONICA_INCLUDE_PATH=D:\leptonica\build\include |
| 66 | set LEPTONICA_LINK_PATHS=D:\leptonica\build\lib |
| 67 | set LEPTONICA_LINK_LIBS=leptonica-1.83.0 |
| 68 | ``` |