1## Building Ricochet
2
3These instructions are intended for people who wish to build or modify Ricochet from source. Most users should [download releases](https://github.com/ricochet-im/ricochet/releases) instead.
4
5Clone with git from `https://github.com/ricochet-im/ricochet.git`, or download source packages [on github](https://github.com/ricochet-im/ricochet/releases). Then proceed to instructions for your platform.
6
7If you're interested in helping to package Ricochet for common Linux platforms, please get in touch!
8
9## Hints
10
11Add `CONFIG+=debug` or `CONFIG+=release` to the qmake command for a debug or release build. Debug builds enable logging to standard output, and shouldn't be used in sensitive environments.
12
13By default, Ricochet will be portable, and configuration is stored in a folder named `config` next to the binary. Add `DEFINES+=RICOCHET_NO_PORTABLE` to the qmake command for a system-wide installation using platform configuration paths instead.
14
15## Linux
16
17You will need:
18 * Qt >= 5.1.0
19 * OpenSSL (libcrypto)
20 * pkg-config
21 * Protocol Buffers (libprotobuf, protoc)
22
23#### Fedora
24```sh
25yum install make gcc-c++ protobuf-devel protobuf-compiler openssl-devel
26yum install qt5-qtbase qt5-qttools-devel qt5-qttools qt5-qtquickcontrols qt5-qtdeclarative qt5-qtbase-devel qt5-qtbase-gui qt5-qtdeclarative-devel qt5-qtmultimedia-devel
27yum install tor # or build your own
28```
29#### Debian & Ubuntu
30```sh
31apt-get install build-essential libssl-dev pkg-config libprotobuf-dev protobuf-compiler
32apt-get install qt5-qmake qt5-default qtbase5-dev qttools5-dev-tools qtdeclarative5-dev qtmultimedia5-dev
33apt-get install qml-module-qtquick-controls qml-module-qtquick-dialogs qml-module-qtmultimedia
34apt-get install tor # or build your own
35```
36
37If the `qml-module-qtquick` packages aren't available, try `qtdeclarative5-controls-plugin` instead.
38
39#### Qt SDK
40The [Qt SDK](https://www.qt.io/download/) is available for most Linux systems and includes an IDE as well as all Qt dependencies.
41
42To build, simply run:
43```sh
44qmake # qmake-qt5 for some platforms
45make
46```
47
48For a system-wide installation, use:
49```sh
50qmake DEFINES+=RICOCHET_NO_PORTABLE
51make
52make install # as root
53```
54
55You must have a `tor` binary installed on the system (in $PATH), or placed next to the `ricochet` binary.
56
57In portable mode (default), all configuration is stored in a folder called `config` with the binary. When installed, the platform's user configuration path is used instead.
58
59The [buildscripts](https://github.com/ricochet-im/buildscripts) repository contains a set of scripts to build a fully static Ricochet on a clean Debian system. These are used to create the generic linux binary packages.
60
61#### Hardening
62Ricochet will use aggressive compiler hardening flags if available. `qmake` will print the results of these tests on first run, or when run with `CONFIG+=recheck`.
63
64To take full advantage of the sanitizer options, you may need to install `libasan` and `libubsan`.
65
66## OS X
67
68You will need:
69 * Xcode (for toolchain)
70 * Qt 5 - preferably the [Qt SDK](https://www.qt.io/download/)
71 * Protocol Buffers (libprotobuf, protoc) - `brew install protobuf`
72
73You can either load `ricochet.pro` in Qt Creator and build normally, or build command-line with:
74```sh
75/path/to/qtsdk/5.3/clang_64/bin/qmake
76make
77```
78
79You also need a `tor` binary in $PATH or inside the build's `ricochet.app/Contents/MacOS` folder. The easiest solution is to use `brew install tor`. If you copy the `tor` binary, you will need to keep it up to date.
80
81Normally, configuration will be stored in a `config.ricochet` folder, in the same location as `ricochet.app`. However, if the bundle is installed to `/Applications`, the system location `~/Library/Application Support/Ricochet` is used instead. You can force that behavior by adding `DEFINES+=RICOCHET_NO_PORTABLE` to the qmake command.
82
83The `packaging/osx/release_osx.sh` script demonstrates how to build a redistributable app bundle.
84
85Since the openssl header files were removed in El Capitan, have qmake use the openssl that comes with brew (see the OPENSSLDIR var below).
86
87Steps:
88```
89brew install protobuf qt5 tor
90/usr/local/opt/qt5/bin/qmake OPENSSLDIR=/usr/local/opt/openssl/ CONFIG+=debug
91make
92```
93
94## Windows
95
96Building for Windows is difficult. The process and scripts used for release builds are documented in the [buildscripts repository](https://github.com/ricochet-im/buildscripts/tree/master/mingw).
97
98For development builds, you will want:
99 * Visual Studio C++ or MinGW
100 * Qt 5 - preferably the [Qt SDK](https://www.qt.io/download/)
101 * OpenSSL (including libs and headers)
102 * Protocol Buffers >= 2.6.0
103
104Compile OpenSSL and protobuf first, according to their instructions.
105
106After installing the Qt SDK, open the `ricochet.pro` project in Qt Creator. Before building, you must click the 'Projects' tab on the left side, and under 'Build Steps', modify 'Additional arguments' to add:
107
108```
109    OPENSSLDIR=C:\path\to\openssl\ PROTOBUFDIR=C:\path\to\protobuf
110```
111
112Use the 'Build -> Run qmake' menu to test your changes.
113
114You also need a `tor.exe` binary, placed in the same folder as `ricochet.exe`.
115
116The windows installer can be built using Inno Setup. See `packaging\installer` for more information.
117