Skip to content

Building from Source Code on Linux and Mac OS X

Alexander Trufanov edited this page Aug 13, 2021 · 18 revisions

Building on Linux

Prerequisites

All requisites should be available for your distribution. The most important are:

  • The basic program build tools. On Ubuntu and Debian these are available in the meta-package build-essential. On other distributions, you may need to install the GNU C++ compiler separately. The package is going to have c++ or g++ in its name. If you can't find the equivalent of build-essential meta-package for your distribution, be sure to install the "make" utility as well.
  • CMake, the cross platform build system.
  • Qt version 5.x . If you have KDE Plasma 5 or later installed then you will have the runtime libraries but you may have to install the header files and utilities. These are in the package qt5-default on Ubuntu and Debian. But generally, developer packages have the -dev or -devel suffix.
  • Several more developer packages:

These are the package names on Debian and Ubuntu, find the similar ones for your distribution. For Fedora, use "-devel" instead of "-dev" as suffix and drop the version numbers.

Package Version Possible Package Names
libjpeg any libjpeg-dev
Fedora: libjpeg-turbo-devel
zlib any zlib1g-dev
libpng any libpng-dev
libtiff any libtiff5-dev
libboost >= 1.35 libboost-all-dev
boost-libs
(if that fails, try: libboost1.62-all-dev)
libcanberra >= 0.30 libcanberra-dev
libopenjp2-7 >= 2.3 libopenjp2-7-dev (optional)

Getting sources

ScanTailor Universal is using some submodules which sources are required to build it. To get sources with all submodules you should clone the ScanTailor project with:
git clone --recurse-submodules https://github.com/trufanov-nok/scantailor.git
Note the --recurse-submodules parameter.

Configuration

Open a console window and go to the directory that contains the scantailor sources. From there, run the following (notice the dots at the end):

mkdir build
cd build
cmake ..

There will be lots of messages from cmake ending with:

- Configuring done 
- Generating done
  • If you have missing dependencies you will get an error message telling you what is missing. You can then search for the missing package and install it.
  • If you have a library and header files installed in a non-standard place then cmake will not find them. In that case you can run the interactive program '''ccmake''' which allows you to specify paths to libraries and header files.

Compilation and Installation

make
sudo make install

(before installation step you may want to run tests with)

make test

Uninstallation

sudo make uninstall

Example

# get compilators and buildchain
sudo apt install cmake gcc g++
# get requiredlibraries
sudo apt install qt5-default libqt5svg5-dev qttools5-dev libtiff5-dev libjpeg-dev libpng-dev libboost-all-dev libcanberra-dev libopenjp2-7-dev
# get git
sudo apt install git

# move to temporary folder
cd /tmp
# getting sourcecode from master branch and storing it in /tmp/scantailor
git clone --recurse-submodules https://github.com/trufanov-nok/scantailor.git

mkdir ./scantailor/build
cd ./scantailor/build
# building sourcecode and testing the app
cmake ..
make && make test
# installing to /usr/local/bin/
sudo make install

Building on Mac OS X (outdated instructions)

MacPorts

MacPorts has already scantailor as a package (Xcode prerequisites for MacPorts apply)

sudo port selfupdate
sudo port install scantailor

Building on Mac OS X is very similar to building on Linux but the package names are different and the MacPorts packaging system needs to be installed in order to get the needed packages. Also the nonstandard location that MacPorts installs qmake to needs to be specified.

Prerequisites

sudo port selfupdate
  • Then install the rest of the needed packages with
sudo port install cmake qt4-mac-devel boost xrender

This installs:

  • CMake, the cross platform build system.
  • Qt version 4.6.0 beta currently
  • Boost version 1.40.0 including libboost
  • libxrender

The rest of the needed packages are installed as dependencies of these.

Configuration

Download the scantailor source code package and then upack the source by entering the following in the directory where the source package resides:

tar xf scantailor-0.9.8.1.tar.gz

Replace the file name above with the name of the version that you have downloaded. Typing the first few letters of the name and typing tab will autocomplete the filename for you.

Then navigate to the directory that contains the scantailor sources. From there, run the following (single line and mind the dot at the end):

cmake -DCMAKE_LIBRARY_PATH=/opt/local/lib -DCMAKE_INCLUDE_PATH=/opt/local/include
-DQT_QMAKE_EXECUTABLE=/opt/local/libexec/qt4-mac-devel/bin/qmake .

There will be lots of messages from cmake ending with

- Configuring done 
- Generating done 
  • If you have missing dependencies you will get an error message telling you what is missing. You can then search for the missing package and install it.
  • If you have a library and header files installed in a non-standard place then cmake will not find them. In that case you can specify them as above for qmake or run the interactive program '''ccmake''' which allows you to specify paths to libraries and header files.

Compilation and Installation

make
sudo make install