LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-12-2005, 10:33 AM   #1
davikevi
LQ Newbie
 
Registered: Feb 2005
Posts: 1

Rep: Reputation: 0
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?

P.S:
This is my helloworld.c file:

#include <gtk/gtk.h>

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

gtk_set_locale();
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);

gtk_widget_show_all(window);
gtk_main();

g_print("bye\n");

return (0);
}
 
Old 02-12-2005, 11:06 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,396

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
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.
 
Old 02-18-2005, 12:40 PM   #3
kpachopoulos
Member
 
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 704

Rep: Reputation: 30
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

Last edited by kpachopoulos; 02-18-2005 at 12:44 PM.
 
Old 02-18-2005, 11:42 PM   #4
skoona
Member
 
Registered: Mar 2004
Location: Indiana, USA
Distribution: Fedora, CentOS, Ubuntu, OS/X Lion
Posts: 80

Rep: Reputation: 16
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.

Code:
$ 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)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gtk-WARNING **: cannot open display gonzalo76 Slackware 18 12-12-2013 10:36 AM
gtk warning cannot open display bosewicht Linux - Newbie 2 03-10-2010 07:53 PM
Gtk-WARNING **: cannot open display: lijomali Fedora 6 11-10-2005 06:43 PM
Gtk-WARNING **: cannot open display ocset Linux - Software 2 10-18-2004 03:18 PM
Gtk-WARNING **: cannot open display: Larsin Linux - Software 1 02-25-2004 10:47 AM


All times are GMT -5. The time now is 04:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration