Build Domoticz from source

From Domoticz
Revision as of 06:14, 2 July 2024 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 !

For Ubuntu/Debian systems issue:

sudo dpkg-reconfigure tzdata

For Raspberry Pi Users:

Log in to your Raspberry with the "pi" user, open the terminal window, and issue:
sudo raspi-config
Using Raspi-config you can 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

For Linux, it is recommended to use GCC 6 or higher, as "-std=c++14" is required.
For Mac OS X, it is recommended to use clang++ / Xcode 5.1, as "-std=c++14 -stdlib=libc++" is required.

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

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


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

Check CMake version

cmake --version


You need CMake version 3.16.0 or higher

If you need to compile/install CMake, then issue the following commands:

Remove any previous CMake installation

sudo apt remove --purge --auto-remove cmake

Go to the official CMake site and download the latest source: http://www.cmake.org/download
The following will assume version 3.28.3 is the latest stable version

wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz
tar xvfz cmake-3.28.3.tar.gz
rm cmake-3.28.3.tar.gz
cd cmake-3.28.3
./bootstrap
make
sudo make install
cd ..
rm -Rf cmake-3.28.3

Please note these steps quite some time. Specially the bootstrap and make command.

Build & Install Boost Libraries

Its recommended that you use the latest Boost libraries.
For this you need to compile/install them by issuing the following commands:

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.84.0 is the latest stable version

wget https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.gz
tar xvfz boost_1_84_0.tar.gz
rm boost_1_84_0.tar.gz
cd boost_1_84_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_84_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 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

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

Refresh the source and build OpenZWave

Initial build:

RPI-3: 4m.30s

RPI-4: 2m.25s

Odroid HC1/2/XU4: 1m.49s

cd open-zwave-read-only
git pull
make

Build domoticz

For the first time, you need to checkout 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