Newbie trying to compile an example program

John (J5) Palmieri johnp at redhat.com
Tue Jun 6 12:06:44 PDT 2006


You have FC-4's version of dbus installed.  You should be running 0.61
in Fedora Core 5.

On Tue, 2006-06-06 at 13:43 -0300, Juan Carlos Castro y Castro wrote:
> I got the example program from 
> http://dbus.freedesktop.org/doc/dbus-tutorial.html (seen below), added 
> an #include <dbus/dbus-glib.h> and tried to compile. I got "undefined 
> symbol" on DBUS_GERROR_REMOTE_EXCEPTION but worked around that. But now 
> I get the following errors while linking. I'm using Fedora 5 and the 
> dbus from its repository (dbus-0.33-3.fc4.1). I have the devel packages 
> installed too, both for it and for glib.
> 
> gcc -ldbus-1 -ldbus-glib-1 -lglib-2.0 -I/usr/include/dbus-1.0 
> -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0 
> -I/usr/lib/glib-2.0/include -o dbustest dbustest.c
> 
> dbustest.c: In function 'main':
> dbustest.c:35: warning: implicit declaration of function 'dbus_g_proxy_call'
> dbustest.c:41: warning: implicit declaration of function 
> 'dbus_g_error_get_name'
> dbustest.c:42: warning: format '%s' expects type 'char *', but argument 
> 2 has type 'int'
> /tmp/cccwlQMO.o(.text+0xb8): In function `main':
> dbustest.c: undefined reference to `dbus_g_proxy_call'
> /tmp/cccwlQMO.o(.text+0xe5):dbustest.c: undefined reference to 
> `dbus_g_error_get_name'
> collect2: ld returned 1 exit status
> 
> I'm doing something stupid, I'm sure. Question is, what?
> 
> ----------------------------------------------------------------------
> #include <stdlib.h>
> #include <dbus/dbus-glib.h>
> 
> int
> main (int argc, char **argv)
> {
>   DBusGConnection *connection;
>   GError *error;
>   DBusGProxy *proxy;
>   char **name_list;
>   char **name_list_ptr;
>  
>   g_type_init ();
> 
>   error = NULL;
>   connection = dbus_g_bus_get (DBUS_BUS_SESSION,
>                                &error);
>   if (connection == NULL)
>     {
>       g_printerr ("Failed to open connection to bus: %s\n",
>                   error->message);
>       g_error_free (error);
>       exit (1);
>     }
> 
>   /* Create a proxy object for the "bus driver" (name 
> "org.freedesktop.DBus") */
>  
>   proxy = dbus_g_proxy_new_for_name (connection,
>                                      DBUS_SERVICE_DBUS,
>                                      DBUS_PATH_DBUS,
>                                      DBUS_INTERFACE_DBUS);
> 
>   /* Call ListNames method, wait for reply */
>   error = NULL;
>   if (!dbus_g_proxy_call (proxy, "ListNames", &error, G_TYPE_INVALID,
>                           G_TYPE_STRV, &name_list, G_TYPE_INVALID))
>     {
>       /* Just do demonstrate remote exceptions versus regular GError */
>       if (error->domain == DBUS_GERROR) /* && error->code == 
> DBUS_GERROR_REMOTE_EXCEPTION) */
>         g_printerr ("Caught remote method exception %s: %s (#%d)",
>                 dbus_g_error_get_name (error),
>                 error->message, error->code);
>       else
>         g_printerr ("Error: %s\n", error->message);
>       g_error_free (error);
>       exit (1);
>     }
> 
>   /* Print the results */
>  
>   g_print ("Names on the message bus:\n");
>  
>   for (name_list_ptr = name_list; *name_list_ptr; name_list_ptr++)
>     {
>       g_print ("  %s\n", *name_list_ptr);
>     }
>   g_strfreev (name_list);
> 
>   g_object_unref (proxy);
> 
>   return 0;
> }
> ----------------------------------------------------------------------
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
-- 



More information about the dbus mailing list