Reputation: 309
I am trying to learn dbus and compilation/linking of programs on Linux. I am fairly new to building and linking applications from scratch. To this end, I am creating a simple client+server applications on Ubuntu which communicate over gdbus. I am using gdbus-codegen tool to generate .c and .h files for the dbus interfaces. I have created a sample xml description file named dbus_interface.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
<node>
<interface name="org.hello.world">
<method name="get_magic_number">
<arg type="i" name="magic_number" direction="out"/>
</method>
</interface>
</node>
and I am generating the code using the following command:
gdbus-codegen --generate-c-code generated_code dbus_interface.xml
which generates the generated_code.c and generated_code.h files. I have included the generated_code.h header file inside my client application, which I am trying to compile with gcc using the following command:
gcc -Wall -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include client.c generated_code.c -o client
However, I get the following error:
generated_code.c:17:12: fatal error: gio/gunixfdlist.h: No such file or directory
17 | # include <gio/gunixfdlist.h>
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
Why is this header file not present on my system? I have the gio directory in /usr/include/glib-2.0/gio, and it contains a bunch of header files - but not gunixfdlist.h.
As a side note:
Upvotes: 2
Views: 1728
Reputation: 57890
The header file is in /usr/include/gio-unix-2.0/gio
. As noted in the documentation:
Note that
<gio/gunixfdlist.h>
belongs to the UNIX-specific GIO interfaces, thus you have to use thegio-unix-2.0.pc
pkg-config file when using it.
So you should be using pkg-config in your project configuration, and make sure that gio-unix-2.0
is included in the invocation that gets your compile flags.
Upvotes: 4