1# Setting up the development environment for GNU/Linux
2
3## Required software
4
5Building OpenToonz from source requires the following dependencies:
6- Git
7- GCC or Clang
8- CMake (3.4.1 or newer).
9- Qt5 (5.9 or newer)
10- Boost (1.55 or newer)
11- LibPNG
12- SuperLU
13- Lzo2
14- FreeType
15- LibMyPaint (1.3 or newer)
16- Jpeg-Turbo (1.4 or newer)
17- OpenCV 3.2 or newer
18
19### Installing Dependencies on Debian / Ubuntu
20
21```
22$sudo apt-get install build-essential git cmake pkg-config libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libqt5multimedia5-plugins libqt5serialport5-dev libsuperlu-dev
23liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 libmypaint-dev libopencv-dev libturbojpeg-dev
24```
25
26For newest versions of OS you may install libmypaint from repository and don't need to build it from source:
27
28```
29$ sudo apt-get install libmypaint-dev
30```
31
32Notes:
33* It's possible we also need `libgsl2` (or maybe `libopenblas-dev`)
34* We may also need `libegl1-mesa-dev libgles2-mesa-dev libglib2.0-dev liblzma-dev`
35* For Qt, MyPaint and OpenCV, you can alternatively build and install from source.
36
37### Installing Dependencies on Fedora
38(it may include some useless packages)
39
40```
41$ sudo dnf install gcc gcc-c++ automake git cmake boost boost-devel SuperLU SuperLU-devel lz4-devel lzma libusb-devel lzo-devel libjpeg-turbo-devel libGLEW glew-devel freeglut-devel freeglut freetype-devel libpng-devel qt5-qtbase-devel qt5-qtsvg qt5-qtsvg-devel qt5-qtscript qt5-qtscript-devel qt5-qttools qt5-qttools-devel qt5-qtmultimedia-devel blas blas-devel json-c-devel libtool intltool make qt5-qtmultimedia
42```
43
44For newest versions of OS you may install libmypaint from repository and don't need to build it from source:
45
46```
47$ sudo dnf install libmypaint-devel
48```
49
50
51### Installing Dependencies on ArchLinux
52
53```
54$ sudo pacman -S base-devel git cmake boost boost-libs qt5-base qt5-svg qt5-script qt5-tools qt5-multimedia lz4 libusb lzo libjpeg-turbo glew freeglut freetype2
55$ sudo pacman -S blas cblas
56```
57From AUR, using eg. yaourt:
58```
59$ yaourt -S superlu libmypaint
60```
61
62Notes:
63* ArchLinux has `blas` split into `blas` and `cblas`.
64
65### Installing Dependencies on openSUSE
66
67```
68$ zypper in boost-devel cmake freeglut-devel freetype2-devel gcc-c++ glew-devel libQt5OpenGL-devel libjpeg-devel liblz4-devel libpng16-compat-devel libqt5-linguist-devel libqt5-qtbase-devel libqt5-qtmultimedia-devel libqt5-qtscript-devel libqt5-qtsvg-devel libtiff-devel libusb-devel lzo-devel openblas-devel pkgconfig sed superlu-devel zlib-devel json-c-devel libqt5-qtmultimedia
69```
70
71For newest versions of OS you may install libmypaint from repository and don't need to build it from source:
72
73```
74$ zypper install libmypaint-devel
75```
76
77## Build libmypaint dependency
78
79If your linux distributions does not have libmypaint package, then build it from the source:
80
81```
82$ git clone https://github.com/mypaint/libmypaint.git -b v1.3.0
83$ cd libmypaint
84$ ./autogen.sh
85$ ./configure
86$ make
87$ sudo make install
88$ sudo ldconfig
89$ cd ..
90```
91
92## Build instructions
93
94### Cloning the GIT Tree
95
96```
97$ git clone https://github.com/opentoonz/opentoonz
98```
99
100### Copying the 'stuff' Directory
101
102TODO: some parts should really be installed in $prefix/ instead... and some other in various cache or user-local places.
103cf. https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
104Until then we just follow the Win32/OSX layout.
105
106The `~/.config/OpenToonz/` directory contains your settings, work and other files.
107
108Initialize this path with the folling commands:
109
110```
111$ mkdir -p $HOME/.config/OpenToonz
112$ cp -r opentoonz/stuff $HOME/.config/OpenToonz/
113```
114
115*Currently this is required to run OpenToonz.*
116
117### Building LibTIFF
118
119TODO: make sure we can use the system libtiff instead and remove this section.
120Features from the modified libtiff are needed currently, so this isn't a simple switch.
121
122```
123$ cd opentoonz/thirdparty/tiff-4.0.3
124$ ./configure --with-pic --disable-jbig
125$ make -j$(nproc)
126$ cd ../../
127```
128
129### Building OpenToonz
130
131```
132$ cd toonz
133$ mkdir build
134$ cd build
135$ cmake ../sources
136$ make -j$(nproc)
137```
138
139The build takes a lot of time, be patient. CMake may not pick up all the required dependencies. On Fedora 30, it can be helpful to use
140```
141$cmake ../sources/ -DSUPERLU_INCLUDE_DIR=/usr/include/SuperLU
142```
143instead of just
144```
145$cmake ../sources/
146```
147
148### Troubleshooting Build Errors
149
150If something doesn't compile or link, please run `make` this way to help spot the problem:
151```
152$ LANG=C make VERBOSE=1
153```
154
155#### Debug Build
156If you need to debug the application, you should be able to use `cmake -DCMAKE_BUILD_TYPE=Debug`.
157
158
159### Running OpenToonz
160
161You can now run the application:
162
163```
164$ LD_LIBRARY_PATH=./lib/opentoonz:$LD_LIBRARY_PATH
165$ ./bin/OpenToonz
166```
167
168### Performing a System Installation
169
170The steps above show how to run OpenToonz from the build directory,
171however you may wish to install OpenToonz onto your system.
172
173OpenToonz will install to `/opt/opentoonz` by default, to do this run:
174
175```
176$ sudo make install
177```
178
179Then you can launch OpenToonz by running `/opt/opentoonz/bin/opentoonz`.
180
181You can change the installation path by modifying the `CMAKE_INSTALL_PREFIX` CMake variable.
182
183----
184
185# Linux Package Definitions
186
187It may be helpful to use existing packages as a reference when creating a package for your own distribution.
188
189- ArchLinux (AUR):
190  https://aur.archlinux.org/packages/opentoonz-git/
191
192- App-Image (Portable):
193  https://github.com/morevnaproject/morevna-builds
194
195