dbus-glib ld error becose of 'dbus_g_connection_setup_with_g_main'

rosen georgiev dewie at abv.bg
Tue Mar 8 11:22:59 PST 2005


i'm sorry to bother you all again but i really haven't made a step forrward on my problem. so i would like to ask if it is possible for somebody to try to compile (actualy linking is the problem) this code. i have no idea where to start looking for a solution. maybe i should get the dbus lib and glib binding from cvs but i think my version is decently recent.

thank You for your time and regards.




#define DBUS_API_SUBJECT_TO_CHANGE

#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <glib.h>

#include <stdio.h>

DBusGConnection *connection;
DBusGProxy *proxy;
DBusGPendingCall *call;
GMainLoop *main_loop;
GError *error;

dbus_int32_t id;

void onHaveAnswer(gpointer data) {
	char *sz;
	printf ( "have answer\n" );
	fflush(stdout);
	call = dbus_g_proxy_begin_call(proxy, "GetAnswer",
			DBUS_TYPE_INT32, &id,
			DBUS_TYPE_INVALID);
	if ( !dbus_g_proxy_end_call(proxy, call, &error,
			DBUS_TYPE_STRING, &sz, DBUS_TYPE_INVALID) )
	{
		fprintf( stderr, "failed end_call msg=%s", error->message );
	}
	else {
		printf( "%s\n", sz );
	}
	g_main_loop_quit(main_loop);
	return;
}

int main(int argc, char **argv) {
	char *sz_ret;
	
	if (argc != 2) {
		fprintf( stderr , "Usage: [%s] question\n", "dbus-test");
		return -1;
	}

	g_type_init();

	error = NULL;
	connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);

	if ( connection == NULL ) {
		fprintf ( stderr , "Connection not established\n" );
		return -1;
	}
	proxy = dbus_g_proxy_new_for_service(connection,
			"org.oi_ya_laddy.AskService",
			"/Asker",
			"org.oi_ya_laddy.AskInterface");
	if ( proxy == NULL ) {
		fprintf ( stderr , "proxy is null\n");
		return -1;
	}
	
	// connect signals
	dbus_g_proxy_connect_signal( proxy, "haveAnswer", G_CALLBACK( onHaveAnswer ), NULL, NULL);
	
	// first call
	call = dbus_g_proxy_begin_call(proxy, "PostQuestion",
			DBUS_TYPE_STRING, argv[1],
			DBUS_TYPE_BOOLEAN, FALSE,
			DBUS_TYPE_INVALID);
	if ( !dbus_g_proxy_end_call(proxy, call, &error,
			DBUS_TYPE_INT32, &id, DBUS_TYPE_INVALID) )
	{
		fprintf(stderr, "failed end_call msg=%s\n", error->message);
		return -1;
	}
	printf( "got id=%i\n", id );
	fflush(stdout);
	main_loop = g_main_loop_new(NULL, TRUE);
	
	dbus_g_connection_setup_with_g_main(connection);
	
	g_main_loop_run(main_loop);
	return 0;
}


-----------------------------------------------------------------
http://gbg.bg/search - Изпробвайте още сега най-добрата българска търсачка!


More information about the dbus mailing list