Build Domoticz from source

From Domoticz
Jump to navigation Jump to search


Note: This guide will also work for most Debian based Linux systems.


There are two ways to install Domoticz:

- Using the precompiled/binary distribution

- Compiling Domoticz from source (Not that difficult if you strictly follow this page)


Preparation

Make sure your system is been setup and have set to the correct date time !

We assume you are using Debian bookworm or higher. If not, you need to install/compile CMake 3.16 or higher!


Make sure your build system is up to date (date/time/packages)

sudo apt-get install -y make gcc g++ libssl-dev git libcurl4-gnutls-dev libusb-dev libsqlite3-dev python3-dev zlib1g-dev liblua5.3-dev uthash-dev wget cmake libmosquitto-dev

If your system has limited memory (Less then 4GB of memory), you (might) need to create a swap file for compilation.

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!)

Compiling

Build & Install Boost Libraries

Domoticz uses part of the Boost library, and for this you need to install them.


Its recommended that you use the latest Boost libraries.

Remove any previous Boost Libraries installation

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

sudo apt remove --purge --auto-remove libboost-dev libboost-thread-dev libboost-system-dev libboost-atomic-dev libboost-regex-dev libboost-chrono-dev

Now build and install the Boost libraries.

(Please be patient with the 'tar' command as this could take minutes! )

Go to the official Boost Library site and download the latest source: https://archives.boost.io/release/
The following will assume version 1.90.0 is the latest stable version

wget https://archives.boost.io/release/1.90.0/source/boost_1_90_0.tar.gz
tar xvfz boost_1_90_0.tar.gz
rm boost_1_90_0.tar.gz
cd boost_1_90_0
./bootstrap.sh
./b2 stage threading=multi link=static --with-thread --with-system
sudo ./b2 install threading=multi link=static --with-thread --with-system
cd ..
sudo rm -Rf boost_1_90_0/

Build Support for OpenZWave 1.6+

If you need support for ZWave, we encourage you to use ZWaveJS2MQTT as open-zwave support is deprecated.

For those who still needs to use OpenZWave, you need to compile OpenZWave 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

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

git clone https://github.com/domoticz/open-zwave open-zwave-read-only
cd open-zwave-read-only
make

Build Domoticz

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

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

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

On a raspberry PI compilation could take a long time.

Initial build:
- RPI-4: 28m

- RPI-5: 10m

Please note that the Domoticz executable could be build inside the 'bin' folder

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

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.

Update Domoticz

Source Update

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

cd dev-domoticz
git pull
make

Notes

Always create a backup of your Domoticz environment before updating! For Beta updates an automatic backup of the complete Domoticz environment is created in domoticz/backups/domoticz_backup_yyyymmdd_hhmmss.tar.gz by the update script.

Additional information

Some extra information not directly needed to build Domoticz from source but potential helpful to some can be found in the Q&A