3

On my system dbus headers are placed in /usr/include/dbus-1.0/dbus/ and dbus-arch-deps.h is other location (what seems to be strange): /usr/lib/x86_64-linux-gnu/dbus-1.0/include/dbus/dbus-arch-deps.h In my program I include #include<dbus-1.0/dbus/dbus.h>but in every header file which include others path looks like this: #include<dbus/xxx.h> I can copy dbus-arch-deps.h to /usr/include/dbus-1.0/dbus/ but how to fix paths in dbus headers ?

Irbis
  • 11,537
  • 6
  • 39
  • 68

3 Answers3

9

Your system likely has pkg-config installed.

g++ $(pkg-config --cflags dbus-1) main.c

Pkgconfig contains a database of linker/compiler/etc. flags that are required to use specific libraries. See man pkg-config for more info.

WGH
  • 3,222
  • 2
  • 29
  • 42
3

First of all you need to install and configure it properly. You should try this command :

sudo apt-get -y install dbus libdbus-1-dev libdbus-glib-1-2 libdbus-glib-1-dev

Now, here is the Makefile that you should write for compiling :

all:
g++ dbus.cpp -I/usr/include/dbus-1.0 \
    -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include \
    -I/usr/include/glib-2.0 \
    -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ \
    -ldbus-1 \
    -ldbus-glib-1

Now, you may include files like dbus/dbus.h, dbus/dbus-glib.h, etc.

shreyans800755
  • 244
  • 1
  • 10
1

You don't need to copy files.

Simply add the path of where dbus is located to your include path when compiling using the I flag:

example:

g++ -Wall -I /usr/include/dbus-1.0/ -o main.o

By using the location of where dbus is located (in the standard location of /usr/include, you can reference the files like the following in your source code:

#include <dbus/xxx.h>

Similarly, if you have to link against dbus you'll have to append that path to the Libraries inclusion path like so:

g++ -Wall -I /usr/include/dbus-1.0/ -o main.o -L <dbus library path>

Where dbus library path is where the libraries ofdbus` live. To figure this out, consult the web, or search your system.

UPDATE:

To achieve that in Qt-Creator (which I've never used), perhaps the following can help:

How to add include path in Qt Creator?

Community
  • 1
  • 1
jrd1
  • 10,358
  • 4
  • 34
  • 51