Compiling Domoticz on MacOS -- update for 10.12.3 Sierra
Posted: Tuesday 07 February 2017 21:11
Building on trixwood’s clear instructions to compile Domoticz for MacOS (http://www.domoticz.com/wiki/Mac_OS_X), I’d thought it might be useful for others to see what has changed since last year. Before I edit the Wiki page let me summarize what I found:
0) I executed the compilation on a fresh (‘virgin’) Parallels MacOS 10.12.3 virtual machine (Parallels) using latest brew and Xcode 8.2.1. To get the virtual machine running without SIP see the end of this post.
1) Installing necessary libraries
brew install boost —with-python: the —with-python option doesn’t exist and is ignored. Can be removed from the instructions.
brew install zlib: brew formula doesn’t exist and this install can be ignored (zlib is present in MacOS/Xcode by default?). Remove from instructions.
brew install openssl: comes with lots of warnings and caveats but is still required to compile Domoticz successfully. The export LDFLAGS and CPPFLAGS statements were of no use (I still ended up with Domoticz compile errors caused by openssl). See export commands below which solved the errors.
brew linkapps python3: brew linkapps is no longer a current brew operation though it still works. Not sure what the effect is if you leave it out (as used to be the case).
2) Compile OpenZWave
I would place this instruction in front of downloading the Domoticz source. For newbies this avoids them installing OpenZWave within the Domoticz folder. Please note the way OpenZWave is installed causes brew doctor to report a lot of warnings of ’unbrewed’ OpenZWave dylib and header files)
Also note I had to use sudo make install (combined with turning off SIP) to get the pkgconfig executable (chown 755) and copied into /usr/lib/pkgconfig.
3) Compile Domoticz
First hurdle to take was to get openssl properly recognized. This required export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/ and export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/.
I had to reference Python 3.6 in the cmake options (I’m glad trixwood had clearly signalled this change in the instructions).
Combined with turning off the Python plugins the cmake working for me was: cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/Headers -DPYTHON_LIBRARY=/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib -DUSE_PYTHON_PLUGINS=NO CMakeLists.txt
Perhaps the following cmake may also work if you have no other Python libraries installed: cmake -DCMAKE_BUILD_TYPE=Release -DUSE_PYTHON_PLUGINS=NO CMakeLists.txt
There are still a lot of warnings listed when compiling Domoticz but these don’t prevent you from generating a MacOS executable!
Procedure to turn off SIP on a Parallels virtual machine:
0. Shutdown your macOS VM.
1. Add to its boot flags (VM config -> Hardware -> Boot Order -> Advanced settings -> Boot flags) string "vm.efi.mac_recovery=1" - this forces VM to boot into Recovery mode.
2. Start your VM and it will be in Recovery.
3. Disable SIP.
4. Shutdown VM.
5. Disable Recovery mode setting boot flat value to "0".
6. Start VM - it will boot normally but without SIP.
0) I executed the compilation on a fresh (‘virgin’) Parallels MacOS 10.12.3 virtual machine (Parallels) using latest brew and Xcode 8.2.1. To get the virtual machine running without SIP see the end of this post.
1) Installing necessary libraries
brew install boost —with-python: the —with-python option doesn’t exist and is ignored. Can be removed from the instructions.
brew install zlib: brew formula doesn’t exist and this install can be ignored (zlib is present in MacOS/Xcode by default?). Remove from instructions.
brew install openssl: comes with lots of warnings and caveats but is still required to compile Domoticz successfully. The export LDFLAGS and CPPFLAGS statements were of no use (I still ended up with Domoticz compile errors caused by openssl). See export commands below which solved the errors.
brew linkapps python3: brew linkapps is no longer a current brew operation though it still works. Not sure what the effect is if you leave it out (as used to be the case).
2) Compile OpenZWave
I would place this instruction in front of downloading the Domoticz source. For newbies this avoids them installing OpenZWave within the Domoticz folder. Please note the way OpenZWave is installed causes brew doctor to report a lot of warnings of ’unbrewed’ OpenZWave dylib and header files)
Also note I had to use sudo make install (combined with turning off SIP) to get the pkgconfig executable (chown 755) and copied into /usr/lib/pkgconfig.
3) Compile Domoticz
First hurdle to take was to get openssl properly recognized. This required export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/ and export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/.
I had to reference Python 3.6 in the cmake options (I’m glad trixwood had clearly signalled this change in the instructions).
Combined with turning off the Python plugins the cmake working for me was: cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/Headers -DPYTHON_LIBRARY=/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib -DUSE_PYTHON_PLUGINS=NO CMakeLists.txt
Perhaps the following cmake may also work if you have no other Python libraries installed: cmake -DCMAKE_BUILD_TYPE=Release -DUSE_PYTHON_PLUGINS=NO CMakeLists.txt
There are still a lot of warnings listed when compiling Domoticz but these don’t prevent you from generating a MacOS executable!
Procedure to turn off SIP on a Parallels virtual machine:
0. Shutdown your macOS VM.
1. Add to its boot flags (VM config -> Hardware -> Boot Order -> Advanced settings -> Boot flags) string "vm.efi.mac_recovery=1" - this forces VM to boot into Recovery mode.
2. Start your VM and it will be in Recovery.
3. Disable SIP.
4. Shutdown VM.
5. Disable Recovery mode setting boot flat value to "0".
6. Start VM - it will boot normally but without SIP.