Visual Studio (or other IDE) setup instructions

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Whiskey
Posts: 6
Joined: Monday 07 May 2018 20:35
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Visual Studio (or other IDE) setup instructions

Post by Whiskey »

Is there someone who can give a brief overview of the steps to take to setup a development environment? I've tried this so far (on Windows):
  • installed VS Community edition
  • cloned the project (Using VS)
  • installed Python3
  • extracted the extra Windows libraries in the MSBuild directory (as stated at the bottom of this page in the wiki)
  • start VS and open the project via the domoticz.sln file in the MSBuild directory
  • set the project->properties->debugging->Working Directory to be the root of the project, as mentioned on the forums here
When compiling it then borks with

Code: Select all

Error	C1083	Cannot open include file: 'boost/thread.hpp': No such file or directory		domoticz	c:\users\whiskey\source\repos\domoticz\main\stdafx.h	57	
It does seem the file it wants is not there. I tried changing the working directory to MSBuild but I then get a whole list of boost dependencies that are not found. By the way, the boost files are there after extracting the zip, but in MSBuild/Boost/Boost/.

I have done a fair bit of development in various languages, but I'm new to C++. Rather then trying to solve this via trial and error I'm hoping for a few pointers ;)

I'm not limited to VS by the way, if development works better on Linux then that's fine too.

Finally, the reason for trying is that I've installed Domoticz on my FreeNAS and noticed the SolarEdge plugin would not work for me. Rather then asking others I'd figure I try a bit of debugging and hopefully use the knowledge to write a hardware module myself someday.
darkeye
Posts: 5
Joined: Wednesday 08 May 2019 22:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by darkeye »

Did you get this working?

Boost library install instructions here.
https://www.domoticz.com/wiki/Raspberry ... rom_source

Just pulled from git to look at the flower care support - I'm getting Lux reading but not the other values.
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by rrozema »

Since this is page that comes up on top on google when looking for instructions how to build Domoticz on windows using visual studio, I'll post the link that helped me here: https://github.com/domoticz/domoticz/bl ... INSTALL.md
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by barts2108 »

Found this forum topic and will continue discussion over here in the forum. The discussion was started on Github but does not belong there. For reference, the link to github : https://github.com/domoticz/domoticz/is ... -757497736

The references post is similar to the INSTALL.md instructions with some items in correct order, and some menu names that are taken from Visual Studio 2019.
Last edited by barts2108 on Monday 11 January 2021 15:00, edited 1 time in total.
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by barts2108 »

I will try to redo the installation on a clean windows, but that may take some time
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by waaren »

barts2108 wrote: Monday 11 January 2021 9:09 Found this forum topic and will continue discussion over here.

Is as the INSTALL.md instructions with some items in correct order, and some menu names that are taken from Visual Studio 2019.
Please keep the discussion on the forum. Domoticz github is for codebugs only.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by barts2108 »

Currently setting up a clean windows virtual machine to test ...
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by barts2108 »

Fresh windows 20H2 (OS Build 19042.746) feature experience pack 120.2212.551.0

(Everywhere <username> is used, replace with the foldername of the actual logged in windows user)
  • install 7-zip (v 19.00)
  • install Visual Studio 2019 Community Edition (online installer) 16.8.4 with these options
    ASP.NET and web development
    .NET desktop development
    Desktop development with C++
  • install git for windows (v 2.30.0-64bit)
    All standard options (just keep on clicking next>)
o Start Visual Studio - Continue without code

o From the Visual Studio menu open a developer command prompt

Code: Select all

	Tools -> Command Line -> Developer Command Prompt

o Close Visual Studio (keep developer command prompt open)

o In the developer command prompt execute (leave the command prompt open)

Code: Select all

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

o Download the WindowsLibraries.7z from https://github.com/domoticz/win32-libraries
and extract the contents into the domoticz\msbuild folder so that you have the
path domoticz\msbuild\Windows Libraries

o In the developer command prompt execute (leave the command prompt open)

Code: Select all

	git clone https://github.com/microsoft/vcpkg.git

o In the developer command prompt execute (leave the command prompt open)

Code: Select all

	cd vcpkg

o In the developer command prompt execute (leave the command prompt open)

Code: Select all

	call bootstrap-vcpkg.bat -disableMetrics

o In the developer command prompt execute (leave the command prompt open)

Code: Select all

	set VCPKG_DEFAULT_TRIPLET=x86-windows
o In explorer find the file domoticz\msbuild\vcpkg-packages.txt copy the contents
and paste it in the next command that must be executed in the developer command
prompt(leave the command prompt open) - this command may take some time to complete

Code: Select all

	vcpkg install [i]<PASTE CONTENT HERE>[/i]

o In the developer command prompt execute the following line (when asked press yes to install)

Code: Select all

	vcpkg.exe integrate install

o Close the developer command prompt
o Open Visual Studio
o From Visual Studio open the domoticz project (domoticz\msbuild\domoticz.sln)

o Right click the domoticz project -> properties
- in Configuration Properties -> Debugging set "Working Directory" to

Code: Select all

		$(ProjectDir)\..
- in Configuration Properties -> Build Events -> Post-Build Event set "Command Line" to

Code: Select all

		copy "$(ProjectDir)Windows Libraries\openzwave\openzwave*.dll" $(OutDir)

o Right click the domoticz project and choose build to build the project. Building ends for me with these lines in the Visual Studio output view

Code: Select all

1>   Creating library C:\Users\<username>\source\repos\domoticz\msbuild\Debug\domoticz.lib and object C:\Users\<username>\source\repos\domoticz\msbuild\Debug\domoticz.exp
1>domoticz.vcxproj -> C:\Users\<username>\source\repos\domoticz\msbuild\Debug\domoticz.exe
1>C:\Users\<username>\source\repos\domoticz\msbuild\Windows Libraries\openzwave\OpenZWave.dll
1>C:\Users\<username>\source\repos\domoticz\msbuild\Windows Libraries\openzwave\OpenZWaved.dll
1>        2 file(s) copied.
1>Done building project "domoticz.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

o Copy the following folders and their contents

C:\Users\<username>\source\repos\domoticz\Config
C:\Users\<username>\source\repos\domoticz\dzVents
C:\Users\<username>\source\repos\domoticz\plugins
C:\Users\<username>\source\repos\domoticz\scripts
C:\Users\<username>\source\repos\domoticz\www

entirly into

C:\Users\<username>\source\repos\domoticz\msbuild\Debug\

o Now you can start domoticz in the C:\Users\<username>\source\repos\domoticz\msbuild\Debug\ folder

NOTE 1:
For building python3 is not needed. For running, it may be needed to install python3

NOTE 2:
If you test with Microsoft Edge, and URL "http://localhost:8080" does not work,
Check https://superuser.com/a/1466252 and if that does not work you can try to open
a cmd prompt with administrator rights and execute the following line

Code: Select all

	CheckNetIsolation LoopbackExempt -a -n=Microsoft.Win32WebViewHost_cw5n1h2txyewy


-- Happy Compiling, Happy Debugging --
mateq
Posts: 1
Joined: Wednesday 17 February 2021 17:25
Target OS: Linux
Domoticz version:
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by mateq »

Hey, Just used the instruction that barts2108 provided, and I have to say it worked. But I have one problem, I would like to use it on the master branch, not the development one. When building it from master branch, the compiler throw over 100 errors:

Severity Code Description Project File Line Suppression State
Error (active) E1696 cannot open source file "stdafx.h" domoticz C:\Users\matte\source\repos\domoticz\hardware\MQTT.cpp 1
Severity Code Description Project File Line Suppression State
Error (active) E1696 cannot open source file "iowin32.h" domoticz C:\Users\matte\source\repos\domoticz\webserver\request_handler.hpp 19

which a lot seems to be related somehow to boost:
Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "_1" is undefined domoticz C:\Users\matte\source\repos\domoticz\hardware\MQTT.cpp 144
(that is the `44 line) m_sDeviceReceivedConnection = m_mainworker.sOnDeviceReceived.connect(boost::bind(&MQTT::SendDeviceInfo, this, _1, _2, _3, _4));

...
Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "m_IsConnected" is undefined domoticz C:\Users\matte\source\repos\domoticz\hardware\MQTT.cpp 665
...
Severity Code Description Project File Line Suppression State
Error C2065 '_1': undeclared identifier domoticz C:\Users\matte\source\repos\domoticz\hardware\RFLinkSerial.cpp 184

Does anyone know how to make it work on master branch, what are the differences between master and development branch that could cause this?
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by rrozema »

I'm still learning in this area myself, but I think you're getting these errors because the version of the libraries and headers installed using vcpkg is more recent than that needed to build the master branch. I have no clue however how/where to obtain a version that could be used to build the master branch.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by waaren »

rrozema wrote: Friday 19 March 2021 17:45 I'm still learning in this area myself, but I think you're getting these errors because the version of the libraries and headers installed using vcpkg is more recent than that needed to build the master branch. I have no clue however how/where to obtain a version that could be used to build the master branch.
Have you tried this one?

https://github.com/domoticz/domoticz/tree/master
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by rrozema »

waaren wrote: Friday 19 March 2021 18:05
rrozema wrote: Friday 19 March 2021 17:45 I'm still learning in this area myself, but I think you're getting these errors because the version of the libraries and headers installed using vcpkg is more recent than that needed to build the master branch. I have no clue however how/where to obtain a version that could be used to build the master branch.
Have you tried this one?

https://github.com/domoticz/domoticz/tree/master
😁 Yes of course. But getting the sources is not the hard part. Getting it to build successfully is. In fact not even the latest can be built atm. Vcpkg won't install. Not on win7 (which I still prefer) nor on win10. I tried to update to latest lib and now it doesn't build anymore
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by waaren »

rrozema wrote: Saturday 20 March 2021 17:39 But getting the sources is not the hard part. Getting it to build successfully is. In fact not even the latest can be built atm. Vcpkg won't install. Not on win7 (which I still prefer) nor on win10. I tried to update to latest lib and now it doesn't build anymore
I did a fresh install 3 days ago (a laptop stopped completely so had to) on windows 10 using this excellent step by step procedure from @barts2108. It did take quite some time but I can build the latest version.
I did not check a build of the stable.

git.png
git.png (15.57 KiB) Viewed 2448 times
compile.png
compile.png (73.11 KiB) Viewed 2448 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by rrozema »

waaren wrote: Saturday 20 March 2021 22:17
rrozema wrote: Saturday 20 March 2021 17:39 But getting the sources is not the hard part. Getting it to build successfully is. In fact not even the latest can be built atm. Vcpkg won't install. Not on win7 (which I still prefer) nor on win10. I tried to update to latest lib and now it doesn't build anymore
I did a fresh install 3 days ago (a laptop stopped completely so had to) on windows 10 using this excellent step by step procedure from @barts2108. It did take quite some time but I can build the latest version.
I did not check a build of the stable.


git.png
compile.png
In my windows 10 machine I uninstalled both visual studio and all libraries installed by vcpkg (vcpkg list and then vcpkg remove <all installed package names>). And no I can build again in at least this machine. It took almost 2 days to do it, but hey, it works again. So thanks :-)
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by rrozema »

in a clean machine install of libwebsockets fails, because it's build fails to find the pthreads executable. This can be easily fixed by first executing

Code: Select all

vcpkg install pthreads
to create the pthreads executable and only then append the contents of the msbuild\vcpkg-packages.txt, which currently means:

Code: Select all

vcpkg install boost cereal curl jsoncpp lua minizip mosquitto openssl pthreads sqlite3 zlib
@barts2108: please remove the whitespace in front of the code lines. if we click the 'select all' link on the code in your excellent walk-through, then copy and paste the result, these spaces/tabs or whatever they are, cause the commands to fail.
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by rrozema »

To enable debugging of domoticz together with openzwave, you can add the openzwave project into the domoticz solution by following the next steps. The same settings can't be used to build the release version, but a release version of the both targets can still be built using the existing cmake build process, this is just to create a debugging environment for the both projects together.

The instructions earlier in this thread describe downloading and extracting the WindowsLibraries 7z file to get all required dependencies to build domoticz. Most of these dependencies are -apart from openzwave- however already also available from the steps installing and running vcpkg. If you want to rebuild the exact same version as the -official- domoticz, please make sure you use the include and library files included in the 7z file. If however you want to use the latest versions of all dependencies, skip the steps with the 7z file and use the headers and libraries provided by the vcpkg procedure. I build my domoticz against the latest dependencies provided by vcpkg, so I did not extract the windowsLibraries 7z. You may have to play around a little with the include paths and the libraries to link to to get it working as you will see further on. Hint: errors compiling ozwcp.cpp are often caused by including python's node.h instead of openzwave's node.h.

We will include the both projects domoticz and openzwave in one solution. Although not required I suggest to pull the both projects into 2 folders based of the same path to make it easy to create the references. In my case I used E:\Github\domoticz as the base folder for both projects (I use domoticz' fork of the openzwave project). So my domoticz source files are in E:\Github\domoticz\domoticz and my openzwave source files are in E:\Github\domoticz\open-zwave.

Here are the steps I followed to set up domoticz and openzwave to build in one solution to enable me to build and debug the both projects together:
  • To get the latest open-zwave project source files in the correct location open a Developer Command Prompt (as described above),
  • Change to the base folder for the both projects:

    Code: Select all

    cd \Github\domoticz
    and press <Enter>.
  • Then execute

    Code: Select all

    git clone https://github.com/domoticz/open-zwave
    and press <Enter>.
  • Open the domoticz project in Visual Studio.
  • Open the Solution Explorer window and right click the top-most entry, called "Solution 'domoticz'". Select "Add" -> "Existing Project..." from the menu.
  • Locate and select the open-zwave vs project file in cpp\build\windows\vs2010\OpenZWave.vcxproj and click the "Open" button. In my case it is at E:\Github\domoticz\open-zwave\cpp\build\windows\vs2010\OpenZWave.vcxproj.
  • OpenZwave needs to be built with the DebugDLL configuration instead of the Debug configuration that is used for domoticz. Right click again the top-most entry "Solution 'domoticz'" in the solution explorer. In the menu select "Configuration manager...".
  • Active solution configuration must be left at "Debug" and Active solution platform remains at "Win32". Do not change the configuration for domoticz, but for project "OpenZWave" change Configuration to "DebugDLL". Platform remains as "Win32". And click the "Close" button.
  • Now, to make the domoticz project reference the open-zwave project, expand the "domoticz" project entry in the Solution Explorer window, and right click the "References" line, the first entry under the project line. In the menu select "Add Reference...".
  • With "Projects" highlighted in the left pane, put a check mark in front of the "OpenZWave" project in the right pane. Then click the "OK" button.
  • The OpenZWave project needs a few settings changed to build correctly. So we locate in the solution explorer window the entry "OpenZWave" and right-click it. From the menu select "Properties".
  • In the left pane select "Configuration Properties" -> "General". Then in the right pane, change "Output Directory" into "$(SolutionDir)Debug\". This will make sure both the dll and the libraries will be available to build and later run domoticz.exe.
    openzwave properties.PNG
    openzwave properties.PNG (28.81 KiB) Viewed 2341 times
  • Next we need to make sure the proper include files are found when building domoticz: In the Solution Explorer window locate and right click the "OpenZWave" project entry. From the menu select "Properties...".
  • In the left pane select "Configuration Properties" -> "VC++ Directories". Then in the right pane locate "Public Include Directories". Add the text "$(VC_SourcePath)cpp\src" as the 1st entry in the list. (Use the button in the right of the field to open an edit window, there use the Add entry button to add a new entry, then locate and add the path). In my case this adds "E:\Github\domoticz\open-zwave\cpp\src". Then click the "OK" button to close the edit window. Next also change the entry for "All Header Files are Public" to "Yes". And then again click the "OK" button to save the settings.
    openzwave vc++ directories.PNG
    openzwave vc++ directories.PNG (54.9 KiB) Viewed 2341 times
  • We want domoticz to work with the dll we're building in this solution, but the domoticz project explicitly links with the library from the windowsLibraries folder, so we need to remove that reference: Right-click the "domoticz" project in the Solution Explorer window. In the left pane highlight "Configuration Properties" -> "Linker" -> "Input", and in the right pane edit the value for "Additional Dependencies" to remove the entry "./Windows Libraries/openzwave/OpenZWaveD.lib" from it. Then click the "OK" button.
  • There is one final thing to do, and that is to delete or rename the file hardware\plugins\include\node.h from the Domoticz project. If you get a list of weird errors while compiling ozwcp.cpp, this file is the cause of it: instead of including openzwave's node.h, this file is included. My assumption is this node.h file was copied into the source tree of domoticz from the python library's public headers at some point, but it is no longer needed because the most recent version of this header file can be found in the headers installed by vcpkg.
Now you should be able to build, execute and debug domoticz and openzwave together by stepping through or setting breakpoints at strategical locations. The first time it will take a long time to start domoticz because of all the downloads of the openzwave configuration files.

edit: made the header include path independent of the installation location
fantom
Posts: 269
Joined: Thursday 26 March 2015 10:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Poland
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by fantom »

I can't build domoticz :(
The latest VS 2022
The latest Win 10
The latest domoticz source

Error C1083 Cannot open include file: 'json/json.h': No such file or directory domoticz
.....\domoticz\main\stdafx.h 59

How can i fix it ?
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by rrozema »

fantom wrote: Sunday 10 April 2022 20:05 I can't build domoticz :(
The latest VS 2022
The latest Win 10
The latest domoticz source

Error C1083 Cannot open include file: 'json/json.h': No such file or directory domoticz
.....\domoticz\main\stdafx.h 59

How can i fix it ?
Did you manage to build domoticz before in this machine or is this the first time you're trying it?

Most of the times the problem with not being able to find the include files, and especially the stdafx.h is a result of not having set up the libraries correctly. i.e. Please follow either barts2108's instructions meticulously including copying the library files to exactly the location specified in the instructions or even better, use vcpkg to install and build the latest libraries and include files in your system before you build domoticz. Instructions on how to get the latest libraries built in your system are in an earlier post of mine here.
redswan
Posts: 15
Joined: Monday 23 October 2017 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11535
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by redswan »

Hi,

So I've finally taken the plunge to try and debug my MQTT AD problem, devices discovered but not created.
If you're interested see forum topic viewtopic.php?p=290737#p290737

I've followed @barts2108's instructions and all went well until the build. It fails with the message "The build tools for v143 cannot be found. Install v143 to build using the v143 build tools."

So what to do try to install these build tools or set the build tools to $(DefaultPlatformToolset)?

Thanks in advance.

Chris
redswan
Posts: 15
Joined: Monday 23 October 2017 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11535
Contact:

Re: Visual Studio (or other IDE) setup instructions

Post by redswan »

Hi again,

I found the answer, install VS2022, I was using VS2019 which uses build tools V142.

Then I got Error C1083 Cannot open include file: 'json/json.h': No such file or directory domoticz .......

This was solved by rerunning the various VCPKG installation steps.

Now I have a running Windows Domoticz instance.

Next step, try to debug it!!

Thanks for your time, sorry to have wasted it.

Chris
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest