All Classes Namespaces Functions Variables Properties Pages
/home/travis/build/chchwy/pencil2d/docs/build_linux.md
1 # Building Pencil2D on Linux
2 
3 These are instructions for building Pencil2D on Linux. If you are using Windows go [here](docs/build_win.md), and macOS go [here](docs/build_mac.md). This guide is primarily targeted towards developers. If you just want to use the latest version you can just download one of our [nightly builds](https://www.pencil2d.org/download/#nightlybuild).
4 
5 This tutorial was made with Ubuntu Xenial Xerus (16.04) and Arch Linux in mind, however you should be able to adapt this guide to other versions or distributions if necessary.
6 
7 ## Installing Dependencies
8 
9 There are a few things that must be installed in order to build Pencil2D. In this section we will go over the installation of each of these components in detail. For Ubuntu we describe both graphical and command-line methods of installation, choose whichever one you feel more comfortable with (and if you don't know the difference, choose graphical). For Arch Linux we describe only the command-line method since that is what most Arch users are used to.
10 
11 ### Qt
12 
13 Pencil2D relies on the Qt application framework so you must install it before you can successfully build the program.
14 
15 #### Ubuntu
16 
17 ##### Graphical method
18 
19 - Go to the [Qt Downloads](https://www.qt.io/download-open-source/) and download the *Qt Online Installer for Linux*.
20 - Executing this file will start the Qt installer application. If you can't open it right away, you may have to right click on it and go to *Properties*, then in the *Permissions* tab select *Allow executing file as program* and then try opening it again.
21 - Click Next. It will give you the option to log in with your Qt developer account. You can skip this if you don't have an account and do not want to register.
22 - Next specify a location for Qt, put it somewhere you can find it in case you ever need to navigate to the Qt files manually.
23 - Next you can select the components you wish to install. At the very least you should have Desktop GCC selected under the latest Qt version. Also make sure Qt Creator under the Tools section is being installed (at the time of writing there is no option to uncheck this, but it's worth double checking!)
24 - Agree to the license and begin the installation. It will take a long time to download all of the files, so be patient. When the installation is complete, press Done and it will launch Qt Creator for you.
25 
26 ##### Command-line method
27 
28 Pencil2D must be built with the Qt 5 framework. To install Qt 5, run this command:
29 
30  sudo apt install qt5-default qt5-qmake libqt5xmlpatterns5-dev libqt5svg5-dev qtmultimedia5-dev
31 
32 If you want to install Qt Creator (recommended), then also run the following command:
33 
34  sudo apt install qtcreator
35 
36 #### Arch Linux
37 
38 Pencil uses version 5 of the Qt framework. To install all required components of Qt, run this command:
39 
40  sudo pacman -S --needed qt5-multimedia qt5-svg qt5-xmlpatterns
41 
42 For a more pleasant development experience, you might want to install Qt Creator as well (recommended). To do so, run the following command:
43 
44  sudo pacman -S --needed qtcreator
45 
46 ### Make and GCC/Clang
47 
48 You will need GNU Make and either GCC or CLANG to build Pencil2D.
49 
50 #### Ubuntu
51 
52 These are usually installed by default, so you don't have to worry about them. If however you encounter issues, you can run the following commands.
53 
54 - GNU Make and GCC:
55 
56  sudo apt install make g++
57 
58 - GNU Make and Clang:
59 
60  sudo apt install make clang
61 
62 #### Arch Linux
63 
64 On most Arch systems, these are installed early on, but if your system does not have them yet, you can install them by running the following commands.
65 
66 - GNU Make and GCC:
67 
68  sudo pacman -S --needed make gcc
69 
70 - GNU Make and Clang:
71 
72  sudo pacman -S --needed make clang
73 
74 ## Building the application
75 
76 Now it's time to build the application. If you do not already have the Pencil2D source, please go over {Downloading Pencil2D Source} (coming soon) before continuing.
77 
78 ### With Qt Creator (recommended)
79 
80 - Open up the Qt Creator application, and from the menu bar select **File** and then **Open File or Project**. Navigate to Pencil2D's root git folder and open the *pencil2d.pro* file.
81 - Next you'll be asked to configure your kits for the project. Kits determine compilers, target environment, and various build settings among other things. The Desktop option should be the only one checked. Click Configure Project to complete the kit selection.
82 - Now all you have to do to build is click the plain **green arrow** in the bottom left corner of the window or press `Ctrl+r` keys. A small progress bar will show up on the bottom right and console output will appear in the bottom section.
83 - If everything goes well then the version of Pencil2D that you build will open up automatically and you're done!
84 
85 If there is an error, the issues tab will open up at the bottom and display the error messages. Try searching it on the [Pencil2D Issue tracker](https://github.com/pencil2d/pencil/issues) or create an issue If you can't find anything. Be sure to include as much detail as you can in your report!
86 
87 ### With QMake/GNU Make
88 
89 If you do not have or do not want to use Qt Creator for some reason then you can follow this two step process. First you have to use QMake to let Qt do its preprocessing and generate the Makefiles. Cd to the root git directory for Pencil2D. To avoid cluttering the source directories with generated files, we’ll create a subdirectory named build for those. For the next step you will need to know the correct mkspec for your computer. Use the table below to find it.
90 
91 | Compiler | 32-bit | 64-bit |
92 | -------- | ------------ | ------------ |
93 | GCC | linux-g++-32 | linux-g++-64 |
94 | Clang | linux-clang | linux-clang |
95 
96 Substitute \<mkspec\> for the mkspec of your desired configuration and run the command below:
97 
98  mkdir build; pushd build; qmake -r -spec <mkspec> CONFIG+=debug ..; popd
99 
100 Next you have to use GNU Make to actually compile the source code. Run the command:
101 
102  make -C build
103 
104 You can then open Pencil2D by running this from the source directory:
105 
106  ./build/bin/pencil2d
107 
108 ## Next steps
109 
110 Now that you can build Pencil2D, the next step is to learn about [navigating the source code](docs/dive-into-code.md).