Raspberry Pi - Build Domoticz from source

From Domoticz
Jump to: navigation, search

There are two ways to install Domoticz, the easy and the hard way. This page explains the hard way. This guide will also work for most Debian based Linux systems.


If you have bought a 'fresh' Pi, you'll need to get your version of Linux to run smoothly.

Log in to your Raspberry with the "pi" user, open the terminal window, and install the required packages by typing this command, followed by enter:

sudo raspi-config

Using Raspi-config you should expand the root filesystem, set your timezone, finish (reboot) and login again. You can find various tutorials on how to do this elsewhere on the internet, or you can check out the tutorial on this wiki: Initial Raspberry Pi Setup


You can also install Domoticz by compiling the source code yourself. The advantage of this is that it should work on most versions of Linux (Debian/Ubuntu tested).

For a manual install see:

Build times reported are when using a Raspberry Pi 3, using "make -j 3"
(Older revisions of the raspberry pi could take up to 10x longer to compile).

You also might need to install:
Linux with g++ 4.7 / 4.8 or higher (requires -std=c++11)
Mac OS X with clang++ / Xcode 4.6 (requires -std=c++11 -stdlib=libc++)

sudo apt-get install cmake make gcc g++ libssl-dev git libcurl4-gnutls-dev libusb-dev python3-dev zlib1g-dev

If you system has limited memory, you might need to create a swap file for compilation. On Debian Stretch you need a swap file if you want to build the debug version.
This can be done by following this tutorial: https://digitizor.com/create-swap-file-ubuntu-linux/
(You do not need to enable the swap file on boot-time!)

Change to your source folder (could be your home folder)

Build & Install Boost Libraries

If this is a clean system, continue at Now build and install the Boost library.

Its recommended that you use the latest Boost libraries - as of December 2017 that is version 1.68.
For this we need to compile/install them by issuing the following commands:
These instructions can also be used on a Linux system.

[This first step is necessary because you will get linking errors if you don't remove the old Boost library]

Instructions here are for removing boost 1.55, on your system this might be another version, so adopt these commands to your need. It could also be you never installed boost on your system, do not worry, just execute the commands

sudo apt-get remove libboost-dev libboost-thread-dev libboost-system-dev libboost-atomic-dev libboost-regex-dev
sudo apt-get remove libboost-date-time1.55-dev libboost-date-time1.55.0 libboost-atomic1.55.0 libboost-regex1.55.0 libboost-iostreams1.55.1
sudo apt-get remove libboost-iostreams1.55.0 libboost-iostreams1.55.0 libboost-iostreams1.55.0
sudo apt-get remove libboost-serialization1.55-dev libboost-serialization1.55.0 libboost-system1.55-dev
sudo apt-get remove libboost-system1.55.0 libboost-thread1.55-dev libboost-thread1.55.0 libboost1.55-dev
sudo apt-get autoremove

Now build and install the Boost library. (Be patience with the 'tar' command as this could take minutes without output!

mkdir boost
cd boost
wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz
tar xfz boost_1_68_0.tar.gz
cd boost_1_68_0/
./b2 stage threading=multi link=static --with-thread --with-system
sudo ./b2 install threading=multi link=static --with-thread --with-system
cd ../../
rm -Rf boost/

Build Support for OpenZWave

If you need support for ZWave, you need to compile open-zwave before compiling domoticz
Make sure to follow the below steps, you will end up with a folder layout like:

- open-zwave-read-only
- dev-domoticz

sudo apt-get install libudev-dev

For the first time, you need to clone the code (copy) from GitHub into your system:

git clone https://github.com/OpenZWave/open-zwave open-zwave-read-only

Refresh the source and build OpenZWave(1m23.057s for initial build (rpi2 3 minutes))

cd open-zwave-read-only
git pull

go back to the top folder (your Home directory) with:

cd .. or cd ~

Domoticz Source

For the first time, you need to checkout the source from GitHub onto your system:

git clone https://github.com/domoticz/domoticz.git dev-domoticz

Build Domoticz (21m15.899s on a raspberry pi 3 , 35m0.646s on a raspberry pi 2 for initial build)

Change to the Domoticz directory, refresh the source and and start building

cd dev-domoticz
git pull
cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt
make -j 3

If CMake complains about not finding zlib, please issue

sudo apt-get install zlib1g-dev

On a raspberry PI compilation could take a long time. Suggested is to use a swap file (see above) and issue 'make' instead of 'make -j3'

Make Domoticz startup at boot time (Also needed for Web Update)

This is NOT needed if you choose the easy way installation.

sudo cp domoticz.sh /etc/init.d
sudo chmod +x /etc/init.d/domoticz.sh
sudo update-rc.d domoticz.sh defaults

Edit the startup script and change the USERNAME, DAEMON and DAEMON_ARGS parameters to reflect your current settings

sudo vi /etc/init.d/domoticz.sh

DAEMON_ARGS="-daemon -www 8080"

If you want to use another web interface port change:

DAEMON_ARGS="-daemon -www 8080"

Test Domoticz (Important to get the file ownerships right!)

cd domoticz
sudo ./domoticz

Start Domoticz

sudo service domoticz.sh start

Now connect with a browser to see if it is up and running.

Updating Domoticz

Binary install update

Use the Web Interface to update Domoticz (Setup->Check for Updates)

If this fails for any reason (e.g. partial download giving segmentation fault) then you should manually update by:


cd domoticz


cd domoticz

Source Update

Login to your Raspberry Pi with the 'pi' user and issue:

cd domoticz
git pull
git checkout tags/4.9700
make -j 4

PS: The tag must be the last tag (in github).