LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 01-19-2009, 01:03 AM   #1
leeward.xie
LQ Newbie
 
Registered: Dec 2008
Posts: 3

Rep: Reputation: 0
Question Why I can't get X Display handle?


I call XOpenDisplay to connect to the X server but get a NULL pointer. My client program run in the text terminal, not GUI desktop. I have got the MIT key using the xauth and set the enviroment variable DISPLAY to "localhost/unix:0". My linux distribution is openSUSE 11.1.

I have test our program on Ubuntu, Debian and SLE10-sp2, it's ok. So I am confused.
 
Old 01-19-2009, 02:08 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
We are all confused, as you havent asked any questions, nore provided any real information. There could be a number of issues, so Ill just list a checklist.

* Does your program work under normal X? (run the program in a xterm or such under a user thats running and using X)
* Can other X programs run under your test conditions? (see if its only your program that has a problem)
* Are you using passing a custom string to XOpenDisplay or are using the normal NULL?
* Try other DISPLAYs, such as ':0' or ':0.0'
 
Old 01-19-2009, 03:43 AM   #3
leeward.xie
LQ Newbie
 
Registered: Dec 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by SciYro View Post
We are all confused, as you havent asked any questions, nore provided any real information. There could be a number of issues, so Ill just list a checklist.

* Does your program work under normal X? (run the program in a xterm or such under a user thats running and using X)
* Can other X programs run under your test conditions? (see if its only your program that has a problem)
* Are you using passing a custom string to XOpenDisplay or are using the normal NULL?
* Try other DISPLAYs, such as ':0' or ':0.0'
Thanks. I'am sorry for my confused question.

>>* Does your program work under normal X? (run the program in a xterm or such under a user thats running and using X)
Yes. All is OK under the GUI desktop enviroment. There is the connection problem under the normal character terminal.

>>* Can other X programs run under your test conditions? (see if its only your program that has a problem)
No. I wrote the program just to test if it's OK to connect to the X server so it's very simple, which just call XOpenDisplay and XCloseDisplay.

>>* Are you using passing a custom string to XOpenDisplay or are using the normal NULL?
>>* Try other DISPLAYs, such as ':0' or ':0.0'
I have tried :0.0, :0, but return error:
No protocol specified
I have tried NULL, localhost/unix:0, localhost:0, localhost/unix:0.0, localhost:0.0, but get NULL Display pointer.
 
Old 01-19-2009, 06:27 AM   #4
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
If the program works under X, then open a xterm and check the DISPLAY ("env | grep DISPLAY"), then set it your terminal according to that.

By any chance did the out was anything useful? If its a permissions error, the output should have something like "connection refused" or somesuch.
 
Old 01-19-2009, 09:53 AM   #5
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
Quote:
If the program works under X, then open a xterm and check the DISPLAY ("env | grep DISPLAY"), then set it your terminal according to that.
Just the opposite, if I read the situation correctly. The program works when he runs it under X on the local host. But when he wants to run it on the desired X server, it doesn't work. Presumably running xterm on that desired X server doesn't work either. I'm hoping he'll correct me if I'm wrong. :)
 
Old 01-19-2009, 07:53 PM   #6
leeward.xie
LQ Newbie
 
Registered: Dec 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by SciYro View Post
If the program works under X, then open a xterm and check the DISPLAY ("env | grep DISPLAY"), then set it your terminal according to that.

By any chance did the out was anything useful? If its a permissions error, the output should have something like "connection refused" or somesuch.
It's not permission problem. I have tested my program under Ubuntu 8.10, Debian (4.0 and 5.0), SLE10-sp2 and all are OK.

I wonder why there is the problem under openSUSE 11.1.

Last edited by leeward.xie; 01-19-2009 at 07:56 PM.
 
  


Reply

Tags
window



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
Problem withChanging DISPLAY environment variable to display on someone else's screen wantsri Linux - Networking 1 10-25-2005 11:14 AM
Tcl Error no display name and no DISPLAY environment variable thinkgeek Programming 5 07-06-2005 10:24 PM
xlsfonts is dependant on DISPLAY setting not working on one display with Redhat iainsear Linux - General 0 12-21-2004 06:24 AM
xlsfonts is dependant on DISPLAY setting not working on one display with Redhat iainsear Linux - General 0 12-21-2004 06:19 AM
RH9 Shrike /sbin/loader display problem with SIS 630 laptop - display is blank ! johnvoisey Red Hat 4 11-01-2003 06:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:26 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration