1d4afb5ceSopenharmony_ci# DBUS Role Support 2d4afb5ceSopenharmony_ci 3d4afb5ceSopenharmony_ci## DBUS-related distro packages 4d4afb5ceSopenharmony_ci 5d4afb5ceSopenharmony_ciFedora: dbus-devel 6d4afb5ceSopenharmony_ciDebian / Ubuntu: libdbus-1-dev 7d4afb5ceSopenharmony_ci 8d4afb5ceSopenharmony_ci## Enabling for build at cmake 9d4afb5ceSopenharmony_ci 10d4afb5ceSopenharmony_ciFedora example: 11d4afb5ceSopenharmony_ci``` 12d4afb5ceSopenharmony_ci$ cmake .. -DLWS_ROLE_DBUS=1 -DLWS_DBUS_INCLUDE2="/usr/lib64/dbus-1.0/include" 13d4afb5ceSopenharmony_ci``` 14d4afb5ceSopenharmony_ci 15d4afb5ceSopenharmony_ciUbuntu example: 16d4afb5ceSopenharmony_ci``` 17d4afb5ceSopenharmony_ci$ cmake .. -DLWS_ROLE_DBUS=1 -DLWS_DBUS_INCLUDE2="/usr/lib/x86_64-linux-gnu/dbus-1.0/include" 18d4afb5ceSopenharmony_ci``` 19d4afb5ceSopenharmony_ci 20d4afb5ceSopenharmony_ciDbus requires two include paths, which you can force by setting `LWS_DBUS_INCLUDE1` 21d4afb5ceSopenharmony_ciand `LWS_DBUS_INCLUDE2`. Although INCLUDE1 is usually guessable, both can be 22d4afb5ceSopenharmony_ciforced to allow cross-build. 23d4afb5ceSopenharmony_ci 24d4afb5ceSopenharmony_ciIf these are not forced, then lws cmake will try to check some popular places, 25d4afb5ceSopenharmony_cifor `LWS_DBUS_INCLUDE1`, on both Fedora and Debian / Ubuntu, this is 26d4afb5ceSopenharmony_ci`/usr/include/dbus-1.0`... if the directory exists, it is used. 27d4afb5ceSopenharmony_ci 28d4afb5ceSopenharmony_ciFor `LWS_DBUS_INCLUDE2`, it is the arch-specific dbus header which may be 29d4afb5ceSopenharmony_cipackaged separately than the main dbus headers. On Fedora, this is in 30d4afb5ceSopenharmony_ci`/usr/lib[64]/dbus-1.0/include`... if not given externally, lws cmake will 31d4afb5ceSopenharmony_citry `/usr/lib64/dbus-1.0/include`. On Debian / Ubuntu, the package installs 32d4afb5ceSopenharmony_ciit in an arch-specific dir like `/usr/lib/x86_64-linux-gnu/dbus-1.0/include`, 33d4afb5ceSopenharmony_ciyou should force the path. 34d4afb5ceSopenharmony_ci 35d4afb5ceSopenharmony_ciThe library path is usually \[lib\] "dbus-1", but this can also be forced if 36d4afb5ceSopenharmony_ciyou want to build cross or use a special build, via `LWS_DBUS_LIB`. 37d4afb5ceSopenharmony_ci 38d4afb5ceSopenharmony_ci## Building against local dbus build 39d4afb5ceSopenharmony_ci 40d4afb5ceSopenharmony_ciIf you built your own local dbus and installed it in /usr/local, then 41d4afb5ceSopenharmony_cithis is the incantation to direct lws to use the local version of dbus: 42d4afb5ceSopenharmony_ci 43d4afb5ceSopenharmony_ci``` 44d4afb5ceSopenharmony_cicmake .. -DLWS_ROLE_DBUS=1 -DLWS_DBUS_INCLUDE1="/usr/local/include/dbus-1.0" -DLWS_DBUS_INCLUDE2="/usr/local/lib/dbus-1.0/include" -DLWS_DBUS_LIB="/usr/local/lib/libdbus-1.so" 45d4afb5ceSopenharmony_ci``` 46d4afb5ceSopenharmony_ci 47d4afb5ceSopenharmony_ciYou'll also need to give the loader a helping hand to do what you want if 48d4afb5ceSopenharmony_cithere's a perfectly good dbus lib already in `/usr/lib[64]` using `LD_PRELOAD` 49d4afb5ceSopenharmony_cilike this 50d4afb5ceSopenharmony_ci 51d4afb5ceSopenharmony_ci``` 52d4afb5ceSopenharmony_ciLD_PRELOAD=/usr/local/lib/libdbus-1.so.3.24.0 myapp 53d4afb5ceSopenharmony_ci``` 54d4afb5ceSopenharmony_ci 55d4afb5ceSopenharmony_ci## Lws dbus api exports 56d4afb5ceSopenharmony_ci 57d4afb5ceSopenharmony_ciBecause of the irregular situation with libdbus includes, if lws exports the 58d4afb5ceSopenharmony_cidbus helpers, which use dbus types, as usual from `#include <libwebsockets.h>` 59d4afb5ceSopenharmony_cithen if lws was compiled with dbus role support it forces all users to take 60d4afb5ceSopenharmony_cicare about the dbus include path mess whether they use dbus themselves or not. 61d4afb5ceSopenharmony_ci 62d4afb5ceSopenharmony_ciFor that reason, if you need access to the lws dbus apis, you must explicitly 63d4afb5ceSopenharmony_ciinclude them by 64d4afb5ceSopenharmony_ci 65d4afb5ceSopenharmony_ci``` 66d4afb5ceSopenharmony_ci#include <libwebsockets/lws-dbus.h> 67d4afb5ceSopenharmony_ci``` 68d4afb5ceSopenharmony_ci 69d4afb5ceSopenharmony_ciThis includes `<dbus/dbus.h>` and so requires the include paths set up. But 70d4afb5ceSopenharmony_ciotherwise non-dbus users that don't include `libwebsockets/lws-dbus.h` don't 71d4afb5ceSopenharmony_cihave to care about it. 72d4afb5ceSopenharmony_ci 73d4afb5ceSopenharmony_ci## DBUS and valgrind 74d4afb5ceSopenharmony_ci 75d4afb5ceSopenharmony_cihttps://cgit.freedesktop.org/dbus/dbus/tree/README.valgrind 76d4afb5ceSopenharmony_ci 77d4afb5ceSopenharmony_ci1) One-time 6KiB "Still reachable" caused by abstract unix domain socket + libc 78d4afb5ceSopenharmony_ci`getgrouplist()` via nss... bug since 2004(!) 79d4afb5ceSopenharmony_ci 80d4afb5ceSopenharmony_cihttps://bugs.debian.org/cgi-bin/bugreport.cgi?bug=273051 81d4afb5ceSopenharmony_ci 82d4afb5ceSopenharmony_ci 83d4afb5ceSopenharmony_ci 84