# Building

## Prerequisites

* installed [Leptonica](http://www.leptonica.org/) including development parts
* installed [cmake](https://cmake.org/) or [autotools] (https://www.gnu.org/software/automake/manual/html_node/Autotools-Introduction.html)
* installed C++ compiller (gcc, clang, MSVC)
* installed [git](https://git-scm.com/)



## Unix-like OS

If you're running a Unix-like OS, such as Linux, BSD, Mac OS X or msys just run:

```
./autogen.sh
./configure
make
make install (or sudo make install)
```


## CMake

CMake requires CMake build installation of Leptonica


### Windows


*Note*: `cat`, `rm` and `dos2unix` tool are part of [git for windows](https://gitforwindows.org/). You can add them to your path with `set PATH=%PATH%;C:\Program Files\Git\usr\bin`. Adjust path `f:\win64` to your Leptonica installation.

```
"c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" x64
set INSTALL_DIR=f:\win64
set INCLUDE_DIR=f:\win64\include
set LIB_DIR=f:\win64\lib
set PATH=%PATH%;%INSTALL_DIR%\bin
```

### Configuration

```
git clone --depth 1 https://github.com/agl/jbig2enc
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%INSTALL_DIR%
cmake --build build --config Release
```

### Install

```
cmake --build build --config Release --target install
```

### Uninstall

```
cat build/install_manifest.txt | dos2unix | xargs rm

```

### Clean

```
rm -r build/*
```