Hi!
I have been looking for a Windows DBus C++ library without much success recently. In the end I have bitten the bullet and ported dbus-cxx from master branch. The port is available here:
The port itself wasn't that hard, but it took some time, perhaps mostly due to the fact I am not a primarily C++ developer. The commit history pretty much explains everything which had to be done, below is a brief summary:
- Moved all POSIX imports from headers to implementations utilising private implementation pattern
- Added a POSIX compatibility layer for poll, read and write (mostly borrowed from https://github.com/libressl-portable/portable/tree/master/include)
- Renamed interface symbols to avoid clashes on Windows
- Changed all boolean operators to symbol-like form, i.e. 'not' -> '!' etc.
- Replaced pthread locks with STD locks where possible and abstracted the rest via platform independent macros
- On Windows, use BoostASIO header-only library for timers (timeout.cpp)
- Clean-up CMake linking to make it platform-independent, e.g. use '-lrt' or '-pthread' only if supported etc.
- Other minor fixes, clean-ups and improvements
As a part of the change I have also added a CMake option to enable/disable building of static libraries.
The port has been tested on Windows7 x64 running Visual Studio 16 (2019) targeting Win32 with all features working as expected:
- Both shared and static library builds (including glibmm)
- Tools
- Examples
- All tests pass, although two filedescriptor tests had to be excluded (because of dbus, not dbus-cxx)
- Packaging works and a nice NSIS GUI installer/uninstaller is generated
- A test CMake project dependent on dbus-cxx, builds, links and runs fine
I have also regression-tested building on Linux (Elementary OS 64, based on 18.04.1-Ubuntu) without any issues.
I haven't opened a Pull Request yet as I wanted to get some feedback/opinions here first.
Regards,
--Stepan