-   Programming (
-   -   Gtk-warning **: Cannot Open Display: (

davikevi 02-12-2005 10:33 AM

Gtk-warning **: Cannot Open Display:
have successfully compiled a helloworld program (helloworld.c) by using:
gcc -o helloworld helloworld.c `gtk-config --libs --cflags`

But I don't know why I got the error: "cannot open display: :0.0" when i enter ./helloworld

I try to enter "xhost +" but I get this error message:
"xhost: unable to open display ":0.0"

I am using the Fedora Core release 1 linux and login as root a/c with
gtk:1.2.10 glib:1.2.10.

how I can solve this problem?

This is my helloworld.c file:

#include <gtk/gtk.h>

gint main(gint argc, gchar *argv[])
GtkWidget *window, *widget;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "hiGTK+");
gtk_window_set_default_size(GTK_WINDOW(window), 140, 40);

gtk_signal_connect(GTK_OBJECT(window), "destroy",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);

widget = gtk_button_new_with_label("hello!");
// widget = gtk_label_new("hello");
gtk_container_add(GTK_CONTAINER(window), widget);



return (0);

acid_kewpie 02-12-2005 11:06 AM

you're running it as root aren't you? don't... run it as the user who is logged into the x server. alternaitevly, run "xhost +localhost" to allow any local user to load X displays.

kpachopoulos 02-18-2005 12:40 PM

What does this message mean? I think it can appear in many different occasions. I just installed xchat as root; it works perfect (as root), although i don't use it. When i "su" as a different user this message appears. Does this have to do with the fact, that i am logged in as root and i am trying to run the program as a user? How can i fix this problem? Thanks

skoona 02-18-2005 11:42 PM

is that the only error message ? error: "cannot open display: :0.0"

gtk rarely gives only one. Anyway, the program looks fine -- unless some of those statements are gtk-+2.0.

note: doing everything as root is BAD practice, that's all. Most things work as root.

Is it possible for you to upgrade to FC3? and trythis again. This is the command I had to use to compile your program.


$ gcc -o helloworld helloworld.c `pkg-config gtk+-2.0 --libs --cflags`
Notice the change from 'gtk-config...' to 'pkg-config gtk+-2.0...'

(please answer - is that the only error message)

All times are GMT -5. The time now is 02:58 PM.