Have you installed the
libdbus-1-dev
? The headers are included in that package, along with everything you need for programming against the library. You might also want to look into
libdbus-cpp-dev
, which appears to offer a CPP wrapper to the dbus library.
Copying the header to your work space is not advised. #include files often refer to other #includes, and you may end up having to copy most of /usr/include into your project directory just to get things to compile.
You need to look to your IDE documentation. It should tell you how to go about adding the right thing to the project file so that the project can find the headers.
If you're compiling by hand, you should know about pkg-config. e.g.
k5054@localhost$ pkg-config --list-all | grep dbus
dbus-1 dbus - Free desktop message bus
k5054@localhost$ pkg-config --cflags --libs dbus-1
-I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1
We can use that to compile from the command line:
g++ $(pkg-config --cflags --libs) program.cpp -o program
If you're using Makefiles, you can use something like
CXXFLAGS = -Wall -Wextra $(shell pkg-config --cflags dbus-1)
LDFLAGS = -lfoo -lbar $(shell pkg-config --libs dbus-1)
...
Since you seem a bit unsure, a reminder:
-I adds a path to the compiler's search path for include files
-L adds a path to the linker's search path for libraries (.so and .a)
-l adds a library name to the linker's list of objects to include when trying to resolve external object names.
Addendum: you can find what package files belong to using apt-file. See
Linux Apt-file Command Help and Examples[
^] Once you've installed and run
apt-file update
you can query the apt-file database for packages that include files with the given name:
$ apt-file search dbus/dbus.h
libdbus-1-dev: /usr/include/dbus-1.0/dbus/dbus.h
libdbus-cpp-dev: /usr/include/core/dbus/dbus.h
This would indicate that the include file dbus/dbus.h is not part of the "common" include files, but is available as bar tof the libdbus-1-dev package.