2

I am new to developing on linux. I would like to write applications that talk on the dbus so I am currently learning the basic concepts of interacting with the dbus.

I'm working on a new-ish raspberry pi 3; i can see dbus folders on various locations on the filesystem. However, when i #include <dbus/bus.h> i already get an error: "unresolved include file" which leads me to believe the library files or developer options are not enabled for the dbus?

I wanted to find out how i can enable the dbus for development?

Thanks in advance.

24 aug 2017 EDIT: I believe i have the necessary library files i.e. (but not limited to...)

/usr/lib/arm-linux-gnueabihf/libdbus-1.a

/usr/include/dbus-1.0/dbus/dbus.h

but how do i point my NetBeans IDE to them while developing on the remote host (the pi)??

28 Aug 2017 EDIT: After installing the dbus-dev libraries. I removed and re-added my raspberry pi as a local host on my NetBeans IDE. Now, when i

#include <dbus/dbus.h> 

Or

#include <dbus.h>

I receive the error: fatal error: dbus/dbus.h: No such file or directory

So, i ended up having to add /usr/include/dbus-1.0;/usr/lib/arm-linux-gnueabihf/dbus-1.0/include in my netbeans project properties - build - c compiler - include directories... which i hope is ok to do bearing in mind i am working on a remote host...

This project now builds successfully. And i have enabled X11 forwarding on my remote host properties. However, when running i receive the following: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.

Dan_R
  • 191
  • 1
  • 3
  • 14
  • 2
    You are compiling on the device itself? Are development files installed on the OS by default? If not, then a "sudo apt-get install libdbus-1-dev" (or something like it) should help. That said, I'd advice not using libdbus if you're starting a new project: it is very low level and frankly painful to work with: GDBus (from libglib2.0-dev) is a vastly better one. – Jussi Kukkonen Aug 23 '17 at 08:07
  • Yes I am compiling on the device itself. I'm not sure if the development files are there, that's the crux of my question really. Do I need to uninstall dbus before installing libdbus-dev or libglib-dev? Thanks for your reply. – Dan_R Aug 23 '17 at 20:56
  • 2
    No, -dev packages contain headers (and some library symlinks) needed for development and are installed in addition to the actual libraries. `apt-cache policy libdbus-1-dev` should tell you if the libdbus dev package is installed or not – Jussi Kukkonen Aug 24 '17 at 08:48
  • Here is the output from the command you provided: apt-cache policy libdbus-1-dev libdbus-1-dev: Installed: (none) Candidate: 1.8.22-0+deb8u1 Version table: 1.8.22-0+deb8u1 0 500 http://mirrordirector.raspbian.org/raspbian/ jessie/main armhf Packages – Dan_R Aug 24 '17 at 17:34
  • I did the following sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev Now I have, apt-cache policy libdbus-1-dev libdbus-1-dev: Installed: 1.8.22-0+deb8u1 Candidate: 1.8.22-0+deb8u1 Version table: *** 1.8.22-0+deb8u1 0 500 http://mirrordirector.raspbian.org/raspbian/ jessie/main armhf Packages 100 /var/lib/dpkg/status – Dan_R Aug 24 '17 at 18:00
  • In my source code i still have the following error;... Unresolved directive #include Analyzed system include paths: /usr/lib/gcc/arm-linux-gnueabihf/4.9/include /usr/local/include /usr/lib/gcc/arm-linux-gnueabihf/4.9/include-fixed /usr/include/arm-linux-gnueabihf /usr/include – Dan_R Aug 24 '17 at 18:04
  • Please include the compile command you use (or what netbeans ends up using) – Jussi Kukkonen Aug 25 '17 at 09:08
  • You'll probably have to tell netbeans the correct compiler and linker flags -- how to do that is a netbeans question... on the command line you would do `pkg-config --cflags dbus-1` to get correct compile flags and `pkg-config --libs dbus-1` to get correct linker flags, and would then use those while compiling and linking – Jussi Kukkonen Aug 25 '17 at 09:14
  • gcc -c -g -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.c then gcc -o dist/Debug/GNU-Linux/dbus_connect_to_bus build/Debug/GNU-Linux/main.o -L. -L. -Wl,-rpath,'.' -ldbus-1 – Dan_R Aug 28 '17 at 20:22

1 Answers1

0

I would like to post my own answer to this question, as I feel it is basically resolved and my question has now evolved into something else:

To overcome the error: fatal error: dbus/dbus.h: No such file or directory

I ended up having to add /usr/include/dbus-1.0;/usr/lib/arm-linux-gnueabihf/dbus-1.0/include in my netbeans project properties - build - c compiler - include directories.

This project now builds successfully onto the remote host (the pi).

Dan_R
  • 191
  • 1
  • 3
  • 14
  • I would like to know if there is a more elegant solution to this. I would welcome any answers/comments. Thank you in advance. – Dan_R Aug 29 '17 at 15:40
  • my question has evolved into the following \n https://stackoverflow.com/questions/45943505/unable-to-autolaunch-a-dbus-daemon-without-a-display-for-x11-netbeans-pi-as-r – Dan_R Aug 29 '17 at 15:55