Build Domoticz from source: Difference between revisions

From Domoticz
Jump to navigation Jump to search
No edit summary
 
 
(3 intermediate revisions by the same user not shown)
Line 14: Line 14:


=Preparation=
=Preparation=
Make sure your system is been setup and have set to the correct date time !<br>
Make sure your system is been setup and have set to the correct date time !
<br>
For Ubuntu/Debian systems issue:
sudo dpkg-reconfigure tzdata


For Raspberry Pi Users:<br>
We assume you are using Debian bookworm or higher. '''<span style="color:red">If not, you need to install/compile CMake 3.16 or higher!</span>'''
Log in to your Raspberry with the "pi" user, open the terminal window, and issue:<br>
 
<code>'''sudo raspi-config'''</code><br>
 
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|Initial Raspberry Pi Setup]]
Make sure your build system is up to date (date/time/packages)<br>
''For Linux, it is recommended to use GCC 6 or higher, as "-std=c++14" is required.''<br>''For Mac OS X, it is recommended to use clang++ / Xcode 5.1, as "-std=c++14 -stdlib=libc++" is required.''<br>
  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
  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.'''
'''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/'''<br>
This can be done by following this tutorial: '''https://digitizor.com/create-swap-file-ubuntu-linux/'''<br>'''(You do not need to enable the swap file on boot-time!)'''
'''(You do not need to enable the swap file on boot-time!)'''
=Compiling=
=Compiling=
<br>Change to your source folder (could be your home folder)<br>
'''Build & Install Boost Libraries'''
 
Domoticz uses part of the Boost library, and for this you need to install them.


===Check CMake version===
cmake --version
<br>'''<span style="color:red">You need CMake version 3.16.0 or higher</span>'''


If you need to compile/install CMake, then issue the following commands:<br><br>
'''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<br>
'''The following will assume version 3.28.3 is the latest stable version'''
<br>
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.<br>
Its recommended that you use the latest Boost libraries.<br>
For this you need to compile/install them by issuing the following commands:<br>


'''Remove any previous Boost Libraries installation'''
'''Remove any previous Boost Libraries installation'''
Line 69: Line 44:


'''Go to the official Boost Library site and download the latest source:'''
'''Go to the official Boost Library site and download the latest source:'''
https://archives.boost.io/release/<br>
https://archives.boost.io/release/<br>'''''The following will assume version 1.90.0 is the latest stable version'''''
'''''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
  wget [https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.gz https://archives.boost.io/release/1.90.0/source/boost_1_90_0.tar.gz]
  tar xvfz boost_1_84_0.tar.gz
  tar xvfz boost_1_90_0.tar.gz
  rm boost_1_84_0.tar.gz
  rm boost_1_90_0.tar.gz
  cd boost_1_84_0
  cd boost_1_90_0
  ./bootstrap.sh
  ./bootstrap.sh
  ./b2 stage threading=multi link=static --with-thread --with-system
  ./b2 stage threading=multi link=static --with-thread --with-system
  sudo ./b2 install threading=multi link=static --with-thread --with-system
  sudo ./b2 install threading=multi link=static --with-thread --with-system
  cd ..
  cd ..
  sudo rm -Rf boost_1_84_0/
  sudo rm -Rf boost_1_90_0/


===Build Support for OpenZWave 1.6+===
===Build Support for OpenZWave 1.6+===
If you need support for ZWave, we encourage you to use ZWaveJS2MQTT as open-zwave support is deprecated.
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
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:
Make sure to follow the below steps, you will end up with a folder layout like:
Line 95: Line 69:
For the first time, you need to clone the code (copy) from GitHub into your system:
For the first time, you need to clone the code (copy) from GitHub into your system:
  <code>git clone</code> <nowiki>https://github.com/domoticz/open-zwave</nowiki> <code>open-zwave-read-only</code>
  <code>git clone</code> <nowiki>https://github.com/domoticz/open-zwave</nowiki> <code>open-zwave-read-only</code>
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
  cd open-zwave-read-only
git pull
  make
  make


===Build domoticz===
===Build Domoticz===


For the first time, you need to checkout domoticz source from GitHub onto your system:
For the first time, you need to checkout the Domoticz source from GitHub onto your system:
  <code>git clone https://github.com/domoticz/domoticz.git dev-domoticz</code>
  <code>git clone https://github.com/domoticz/domoticz.git dev-domoticz</code>
Change to the Domoticz directory, refresh the source and and start building
Change to the Domoticz directory, refresh the source and and start building
Line 121: Line 86:
On a raspberry PI compilation could take a long time.
On a raspberry PI compilation could take a long time.


Initial build:<br>
Initial build:<br>- RPI-4: 28m
RPI-4: 28m, RPI-5: 10m<br>
 
- RPI-5: 10m<br>


''Please note that the Domoticz executable could be build inside the 'bin' folder''
''Please note that the Domoticz executable could be build inside the 'bin' folder''
Line 144: Line 110:


===Notes===
===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.
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.
 
<br />


=Additional information=
=Additional information=


Some extra information not directly needed to build domoticz from source but potential helpful to some can be found [https://www.domoticz.com/wiki/Build_Domoticz_from_source_Q%26A in the Q&A]  
Some extra information not directly needed to build Domoticz from source but potential helpful to some can be found [https://www.domoticz.com/wiki/Build_Domoticz_from_source_Q%26A in the Q&A]  
 
[[Category:Domoticz]]
          [[Category:Domoticz]]        
[[Category:Manual]]
         
[[Category:Install]]
          [[Category:Manual]]        
[[Category:Raspberry Pi]]
         
[[Category:Debian]]
          [[Category:Install]]        
         
          [[Category:Raspberry Pi]]        
         
          [[Category:Debian]]
{{DEFAULTSORT:Build Domoticz from source}}
{{DEFAULTSORT:Build Domoticz from source}}

Latest revision as of 08:08, 4 February 2026


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