libgudevxx is a C++20 wrapper for libgudev, which is a GObject wrapper for libudev, which is
a library for the udev Linux kernel subsystem.
This library makes it safer to integrate libgudev into GTK+/GLib and gtkmm/glibmm
applications written in C++, by using RAII and type safety. Note that this library does
not depend on glibmm, it comes with its own thin wrapper to convert GLib data types to C++
types.
The API mimics libgudev, so you should consult the libgudev documentation for reference.
The library provides 3 classes in the namespace gudev:
-
gudev::Client: allows you to obtain a device (or a list of all devices in a subsystem). It can also listen for the"uevent"signal, if there's a GLib event loop running. Either assign a lambda touevent_callbackmember variable, or inherit from this class (overriding theon_uevent()method) to catch these events. This is how you can track device changes. -
gudev::Device: holds metadata about a device. The most useful ones are name, device file path, properties and tags. -
gudev::Enumerator: provides querying rules to obtain lists of devices.
These classes are defined in their respective headers:
#include <gudevxx/Client.hpp>
#include <gudevxx/Device.hpp>
#include <gudevxx/Enumerator.hpp>You can also just include <gudevxx/gudevxx.hpp> to include all headers.
A pkg-config script is available, libgudevxx.pc, that helps with compiler and linker
flags:
g++ -std=c++20 test_prog.cpp `pkg-config --cflags --libs libgudevxx`
There's no short example to embed here yet. Check out the examples directory.
-
A C++20 compiler with an adequate C++ development environment. This is usually done by installing some meta package like
task-c++orbuild-essential. In addition, you may need to manually install:autoconfautomakelibtoolpkg-config
-
libgudev: you will need the "devel" version of the package.
-
glibmm: Optional, for building examples, you'll need the "devel" version of the package.
If you downloaded a release tarball, you can skip step 0.
bootstrap./configuremakesudo make install
For more installation options, see INSTALL or the output of ./configure --help.