Kodi Community Forum

Full Version: New in development Kodi c++
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, 
Sorry for the bad english but i need to use google translate.

my intention is to start developing a pvr client, but i have to start getting familiar with c ++ too.
I started by developing an addon in Python, and now I would like to switch to c ++ but I have problems getting the documentationfor create the development environment and compile the pvr.demo.
The first thing I did was to download the Kodi source with Git, following this:
https://github.com/xbmc/xbmc/blob/master...Windows.md
then I manually compiled by following from point 6 the readme.md.
Now I find a path of this type: D:\Projects\xbmx\kodi-build\
But now?
If I want compile pvr.demo-Master and follow this: https://forum.kodi.tv/showthread.php?tid=219166, which path should i use?
If I do:
make -DADDONS_TO_BUILD = "pvr.demo" -DADDON_SRC_PREFIX = "D:\Projects" -DCMAKE_BUILD_TYPE = Debug -G "Visual Studio 16 2019" -DCMAKE_USER_MAKE_RULES_OVERRIDE = "D: \ Projects \ xbmx project" \ c-flag-overrides.cmake "-DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX =" D:\Projects\xbmx\xbmc\project\cmake\scripts\windows\cxx-flag-overrides.cmake "-DCMAKE_INSTALL_PREFIX =" D:\Projects\xbmx\addons" -DBUILD_DIR ="D:\Projects\xbmx\xbmc\project\cmake\addons\build"-DPACKAGE_ZIP = 1" D:\Projects\xbmx\xbmc\project\cmake\addons" to get started, these problems come up:
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/CMakeRCInformation.cmake:27 (include):
  include could not find load file:
    D:\Projects\xbmx\xbmc\project\cmake\scripts\windows\c-flag-overrides.cmake
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.17/Modules/Platform/Windows-MSVC.cmake:439 (enable_language)
  C:/Program Files/CMake/share/cmake-3.17/Modules/Platform/Windows-MSVC.cmake:423 (__windows_compiler_msvc_enable_rc)
  C:/Program Files/CMake/share/cmake-3.17/Modules/Platform/Windows-MSVC-C.cmake:5 (__windows_compiler_msvc)
  C:/Program Files/CMake/share/cmake-3.17/Modules/CMakeCInformation.cmake:48 (include)
  CMakeLists.txt:2 (project)

CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/CMakeCXXInformation.cmake:89 (include):
  include could not find load file:

    D:\Projects\xbmx\xbmc\project\cmake\scripts\windows\cxx-flag-overrides.cmake
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)

CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "FindKodi.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Kodi", but
  CMake did not find one.

  Could not find a package configuration file provided by "Kodi" with any of
  the following names:

    KodiConfig.cmake
    kodi-config.cmake

  Add the installation prefix of "Kodi" to CMAKE_PREFIX_PATH or set
  "Kodi_DIR" to a directory containing one of the above files.  If "Kodi"
  provides a separate development package or SDK, be sure it has been
  installed.
I'm decide to resetting all enviromnent, so deleted all old path and restart with:
d:
d.\mkdir Test
cd Test4
git clone https://github.com/xbmc/xbmc kodi
cd kodi\tools\buildsteps\windows\x64\
download-dependencies.bat
download-msys2.bat
make-mingwlibs.bat
cd ..
mkdir kodi-build
cd kodi-build
cmake -G "Visual Studio 16 2019" -T host=x64 ../kodi
after rebuild for debug:
cmake --build . --config "Debug"
and Kodi compiled witout problem, with a kodi.exe in .\Debug folder and a kodi.sln in d:\Test\kodi-build
Wher i must git clone the pvr.demo-Matrix ? in which folder?

Thank's
(2020-04-27, 15:30)ssdanie Wrote: [ -> ]I'm decide to resetting all enviromnent, so deleted all old path and restart with:
d:
d.\mkdir Test
cd Test4
git clone https://github.com/xbmc/xbmc kodi
cd kodi\tools\buildsteps\windows\x64\
download-dependencies.bat
download-msys2.bat
make-mingwlibs.bat
cd ..
mkdir kodi-build
cd kodi-build
cmake -G "Visual Studio 16 2019" -T host=x64 ../kodi
after rebuild for debug:
cmake --build . --config "Debug"
and Kodi compiled witout problem, with a kodi.exe in .\Debug folder and a kodi.sln in d:\Test\kodi-build
Wher i must git clone the pvr.demo-Matrix ? in which folder?

Thank's

But if i try to open the kodi.sln with Visual Studio 2019:

C:\Test\kodi-build\kodi.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\ALL_BUILD.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\jsonschemabuilder\JsonSchemaBuilder.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\RUN_TESTS.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\ZERO_CHECK.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\check.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\check-commits.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\compileinfo.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\crossguid.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdcss.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdnav.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdread.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\Effects11\effects11.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\export-files.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\interfaces\json-rpc\schema\generate_json_header.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\guilib\generate_shaders.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\kodi-libraries.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\kodi-test.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\libkodi.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\pack-skins.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\swig\python_binding.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\resources.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\cores\RetroPlayer\messages\retroplayer_messages.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\upnp\upnp.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
(2020-04-27, 15:46)ssdanie Wrote: [ -> ]
(2020-04-27, 15:30)ssdanie Wrote: [ -> ]I'm decide to resetting all enviromnent, so deleted all old path and restart with:
d:
d.\mkdir Test
cd Test4
git clone https://github.com/xbmc/xbmc kodi
cd kodi\tools\buildsteps\windows\x64\
download-dependencies.bat
download-msys2.bat
make-mingwlibs.bat
cd ..
mkdir kodi-build
cd kodi-build
cmake -G "Visual Studio 16 2019" -T host=x64 ../kodi
after rebuild for debug:
cmake --build . --config "Debug"
and Kodi compiled witout problem, with a kodi.exe in .\Debug folder and a kodi.sln in d:\Test\kodi-build
Wher i must git clone the pvr.demo-Matrix ? in which folder?

Thank's

But if i try to open the kodi.sln with Visual Studio 2019:

C:\Test\kodi-build\kodi.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\ALL_BUILD.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\jsonschemabuilder\JsonSchemaBuilder.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\RUN_TESTS.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\ZERO_CHECK.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\check.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\check-commits.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\compileinfo.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\crossguid.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdcss.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdnav.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdread.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\Effects11\effects11.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\export-files.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\interfaces\json-rpc\schema\generate_json_header.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\guilib\generate_shaders.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\kodi-libraries.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\kodi-test.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\libkodi.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\pack-skins.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\swig\python_binding.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\resources.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\cores\RetroPlayer\messages\retroplayer_messages.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\upnp\upnp.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM. 
After remove the folder .vs from d:\Test\kodi-build the kodi.sln load correctly and i can lunch the solution in visula studio 2019 correctly with target platform x64 and debug.
Now how i can start to use that environment to load the source of pvr.demo?

Thanks.
(2020-04-27, 16:35)ssdanie Wrote: [ -> ]
(2020-04-27, 15:46)ssdanie Wrote: [ -> ]
(2020-04-27, 15:30)ssdanie Wrote: [ -> ]I'm decide to resetting all enviromnent, so deleted all old path and restart with:
d:
d.\mkdir Test
cd Test4
git clone https://github.com/xbmc/xbmc kodi
cd kodi\tools\buildsteps\windows\x64\
download-dependencies.bat
download-msys2.bat
make-mingwlibs.bat
cd ..
mkdir kodi-build
cd kodi-build
cmake -G "Visual Studio 16 2019" -T host=x64 ../kodi
after rebuild for debug:
cmake --build . --config "Debug"
and Kodi compiled witout problem, with a kodi.exe in .\Debug folder and a kodi.sln in d:\Test\kodi-build
Wher i must git clone the pvr.demo-Matrix ? in which folder?

Thank's

But if i try to open the kodi.sln with Visual Studio 2019:

C:\Test\kodi-build\kodi.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\ALL_BUILD.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\jsonschemabuilder\JsonSchemaBuilder.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\RUN_TESTS.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\ZERO_CHECK.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\check.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\check-commits.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\compileinfo.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\crossguid.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdcss.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdnav.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\dvdread.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\Effects11\effects11.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\export-files.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\interfaces\json-rpc\schema\generate_json_header.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\guilib\generate_shaders.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\kodi-libraries.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\kodi-test.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\libkodi.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\pack-skins.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\swig\python_binding.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\resources.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\cores\RetroPlayer\messages\retroplayer_messages.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.
C:\Test\kodi-build\build\upnp\upnp.vcxproj : error  : Errore HRESULT E_FAIL restituito da una chiamata a un componente COM.  
After remove the folder .vs from d:\Test\kodi-build the kodi.sln load correctly and i can lunch the solution in visula studio 2019 correctly with target platform x64 and debug.
Now how i can start to use that environment to load the source of pvr.demo?

Thanks. 

All fine thanks..
kodi.sln and kodi-addons.sln correctly open with Visual Studio 2019..

Is this the rigth forum for ask support?
Hi ssdanie, seems like you have it under control, but the root of most of the issues is likely that Kodi (Leia and master branches) are set up to build with VS2017 as opposed to VS2019.  I use VS2019 with the v141 toolsets installed to build Kodi.  Here's how I make that work, if it's assistive to you.

Open "Developer Command Prompt for VS 2019"

Build Prep:
txt:
git clone https://github.com/xbmc/xbmc
cd xbmc\tools\buildsteps\windows\x64
download-dependencies.bat (note: repeat until successful)
download-msys2.bat
make-mingwlibs.bat

Build:
txt:
mkdir xbmc-build
cd xbmc-build
cmake -G "Visual Studio 16 2019" -Ax64 -Tv141,version=14.16,host=x64 d:\xbmc\
cmake --build . --config "Release"

The trick to making sure you're using the right toolset is adding the -Tv141,version=14.16 argument to the cmake command line.  I don't use the Solution file, I've gotten used to doing everything from the command line myself.

Also, here is a sample of how I build the "pvr.hdhomerun" addon in the same environment - VS2019 with the v141 toolsets installed. In this example, Kodi has been cloned to d:\git\xbmc\, and all of the above steps have already been executed.

txt:
set ROOT=D:\git\
cmake -G "Visual Studio 16 2019" -Tv141,version=14.16,host=x64 -DADDONS_TO_BUILD=pvr.hdhomerun -DCMAKE_BUILD_TYPE=Debug -DADDON_SRC_PREFIX=%ROOT% -DCMAKE_INSTALL_PREFIX=D:\git\xbmc\addons -DCMAKE_USER_MAKE_RULES_OVERRIDE=D:\git\xbmc\cmake\scripts\windows\CFlagOverrides.cmake -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=D:\git\xbmc\cmake\scripts\windows\CXXFlagOverrides.cmake -DPACKAGE_ZIP=1 D:\git\xbmc\cmake\addons

I hope this helps you out a bit.  Given that all the instructions are for Visual Studio 2017, you might find less aggravation using that instead of Visual Studio 2019.  Best of luck my friend!
(2020-05-02, 03:50)djp952 Wrote: [ -> ]Hi ssdanie, seems like you have it under control, but the root of most of the issues is likely that Kodi (Leia and master branches) are set up to build with VS2017 as opposed to VS2019.  I use VS2019 with the v141 toolsets installed to build Kodi.  Here's how I make that work, if it's assistive to you.

Open "Developer Command Prompt for VS 2019"

Build Prep:
txt:
git clone https://github.com/xbmc/xbmc
cd xbmc\tools\buildsteps\windows\x64
download-dependencies.bat (note: repeat until successful)
download-msys2.bat
make-mingwlibs.bat

Build:
txt:
mkdir xbmc-build
cd xbmc-build
cmake -G "Visual Studio 16 2019" -Ax64 -Tv141,version=14.16,host=x64 d:\xbmc\
cmake --build . --config "Release"

The trick to making sure you're using the right toolset is adding the -Tv141,version=14.16 argument to the cmake command line.  I don't use the Solution file, I've gotten used to doing everything from the command line myself.

Also, here is a sample of how I build the "pvr.hdhomerun" addon in the same environment - VS2019 with the v141 toolsets installed. In this example, Kodi has been cloned to d:\git\xbmc\, and all of the above steps have already been executed.

txt:
set ROOT=D:\git\
cmake -G "Visual Studio 16 2019" -Tv141,version=14.16,host=x64 -DADDONS_TO_BUILD=pvr.hdhomerun -DCMAKE_BUILD_TYPE=Debug -DADDON_SRC_PREFIX=%ROOT% -DCMAKE_INSTALL_PREFIX=D:\git\xbmc\addons -DCMAKE_USER_MAKE_RULES_OVERRIDE=D:\git\xbmc\cmake\scripts\windows\CFlagOverrides.cmake -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=D:\git\xbmc\cmake\scripts\windows\CXXFlagOverrides.cmake -DPACKAGE_ZIP=1 D:\git\xbmc\cmake\addons

I hope this helps you out a bit.  Given that all the instructions are for Visual Studio 2017, you might find less aggravation using that instead of Visual Studio 2019.  Best of luck my friend!

Thak's for the triks! But i think to have a VS2019 solution correctly compilable.. Now i need to know, when i load the kodi.sln and i add the kodi-addons.sln to the project, when i make same code changin, where i found the addon compiled? how i can test/debug/lunch? 
Usually, when i use VS, to try the new edit in the code, i lunch the current solution with the play button in the VS, and the code came compiled and lunched.. but now, i think the addon compiled go in different folder than kodi.sln, so when i lunch the debug of that, the kodi that start don't have the new code, and the addon that i have edited.
the my structure is:
C:\Test\kodi
where there is cmake folder
C:\Test\kodi-build
where there is the kodi.sln, to that solution i added the C:\Test\kodi\cmake\addons\build\kodi-addons.sln, and i can see the pvr.demo addon code, but if i edit the pvr.demo/client.cpp or pvr.demo/PVRDemoData.cpp, and i click the play button, the kodi that start don't have the addon pvr.demo, only if i copy from test\kodi\addons to test\kodi-build\addons i have the addons in the compiled kodi.

Thank's friend!!
When using the IDE, I add a Post-Build custom step to copy the .DLL and .PDB to the installed location, overwriting the existing one(s).  Then I set the Debugging options to launch kodi.exe.  This allows the debugger to breakpoint in your DLL when it's accessed.

Example: I have my kodi set up in "portable" mode, in D:\kodi-sxs\Matrix-x64.  My addon's installed directory is D:\kodi-sxs\Matrix-x64\portable_data\addons\myaddon.  I use this post-build step on my project:

txt:
copy /y $(TargetDir)myaddon.dll D:\kodi-sxs\Matrix-x64\portable_data\addons\myaddon\
copy /y $(TargetDir)myaddon.pdb D:\kodi-sxs\Matrix-x64\portable_data\addons\myaddon\

My debugging options for the project are set up as:

txt:
Command: D:\kodi-sxs\Matrix-x64\kodi.exe
Command Arguments: -p
Working Directory: D:\kodi-sxs\Matrix-x64\

This works for me, anyway, there are lots of ways to make it work.  For debugging a full kodi build I always just copy the .exe and .pdb over the existing ones in the target directory, I never use the IDE for full Kodi builds, always command line.  Since I use the IDE for my addon development, it's easy enough to just use the same things as above and set my breakpoints in the source file I'm interested in. As long as you remember to recopy the .exe and .pdb after you change anything "it just works".  If you don't, Visual Studio will let you know that breakpoint(s) can't be hit since the source is different.

Hope this helps!