Fatal error: dbus/dbus.h: No such file or directory

Hello,

I am trying to use dbus in my C++ program on the Apalis iMX8 on Ixora.
I am using VSCode with the Torizon early access extension.

I am getting the error
fatal error: dbus/dbus.h: No such file or directory
#include <dbus/dbus.h>

I have tried the following options.
For Torizon extension in volumes, I have added the following.
/usr/include/dbus-1
/usr/share/dbus-1/services
/var/run/dbus

Added libdbus-1-3 in extrapackages.

Added libdbus-1-dev:#%platform.debian-arch%# in devpackages.

In tasks.json, I have added the option “-ldbus-1”.

But in spite of adding these, I am still getting the above dbus error.

Hi @SJ_BHD ,

You don’t need to add these volumes for this issue in particular. You correctly added libdbus to devpackages and extrapackages, but looking at the Debian file list for the dev package shows us that the header files are not in the standard include path.

Try doing the following:

  • Add libdbus-1-3 in extrapackages;
  • Add libdbus-1-dev:#%platform.debian-arch%# in devpackages;
  • Rebuild the SDK container when prompted
    (you can also do so manually by pressing F1 then selecting Torizon: Rebuild SDK and reload in container);
  • Change .vscode/c_cpp_properties.json to have the following includePath:
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/dbus-1.0",
                "/usr/lib/aarch64-linux-gnu/dbus-1.0/include"
            ],
  • Add these options to .vscode/tasks.json:
                "-I/usr/include/dbus-1.0",
                "-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include",
                "-ldbus-1"

After doing the steps above, try building the program. Let me know if this helps you.

Best regards,
Lucas Akira

1 Like

Thanks Lucas.
This has resolved the error seen.

Glad I was able to help!

Best regards,
Lucas Akira