[packagekit] Problem running example from FAQ

Richard Hughes hughsient at gmail.com
Tue Aug 5 23:23:16 PDT 2008


On Tue, 2008-08-05 at 15:57 -0700, Dorian Perkins wrote:
> Hello Again,
> 
> After some help in #packagekit (thanks to james_w), I am currently
> using the following compile command:
> 
> gcc $(pkg-config --cflags dbus-glib-1) installer.c 

Sure, I would use something similar:

gcc -o installer -Wall installer.c `pkg-config --cflags --libs dbus-glib-1`

> I am currently getting the following compile time errors:

Right, the code I put up on the FAQ was meant to be copied and pasted
into a program (a snippet), rather than compiled ready to run demo. If
you want a demo, just surround it with some main braces like this:

#include <dbus/dbus-glib.h>

/**
 * main:
 **/
int
main (int argc, char *argv[])
{
        DBusGConnection *connection;
        DBusGProxy *proxy;
        GError *error = NULL;
        gboolean ret;

        connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
        proxy = dbus_g_proxy_new_for_name (connection,
                                           "org.freedesktop.PackageKit",
                                           "/org/freedesktop/PackageKit",
                                           "org.freedesktop.PackageKit");

        /* execute sync method */
        ret = dbus_g_proxy_call (proxy, "InstallPackageName", &error,
                                 G_TYPE_STRING, "openoffice-clipart",
                                 G_TYPE_INVALID, G_TYPE_INVALID);
        if (!ret) {
                g_warning ("failed: %s", error->message);
                g_error_free (error);
        }
        return 0;
}

> P.S. On a side note, the python example at
> http://www.packagekit.org/pk-faq.html#session-methods works just fine.
> Not sure why I am having so much trouble getting the C example to
> work.

I'll make the FAQ clearer, and add the compile line. Apologies for the
confusion.

Richard.






More information about the PackageKit mailing list