XOpenDisplay fails

Investigation into how Linux on the PS3 might lead to homebrew development.

Moderators: cheriff, emoon

Post Reply
KriS
Posts: 6
Joined: Fri Nov 13, 2009 8:12 pm
Contact:

XOpenDisplay fails

Post by KriS »

Hi,

I'm trying to create a window for my spu software rasterizer (fb approach isn't very crash friendly). I'm using YDL 6.2 distro and GCC 4.3.2.

Code: Select all

int main()
{
    if ( !XOpenDisplay( NULL ) )
    {
        printf( "Can't connect to x server" );
    }

    return 0;
}
Everything works fine when I compile this source with -m32 (32 bit executable), but when I try -m64 XOpenDisplay always returns NULL. I tried to update libX11 (from Fedora repos), reinstalled YDL 6.2, played with xhost, but nothing worked.



EDIT: XOpenDisplay( "NULL" ) -> XOpenDisplay( NULL )
Last edited by KriS on Thu Jan 14, 2010 7:16 pm, edited 1 time in total.
User avatar
jbit
Site Admin
Posts: 293
Joined: Sat May 28, 2005 3:11 am
Location: København, Danmark
Contact:

Post by jbit »

First hit on google for XOpenDisplay: http://tronche.com/gui/x/xlib/display/opening.html
display_name: Specifies the hardware display name, which determines the display and communications domain to be used. On a POSIX-conformant system, if the display_name is NULL, it defaults to the value of the DISPLAY environment variable.

This probably means it wants you to use: XOpenDisplay(NULL);... not passing NULL as a string....

There are plenty of xlib tutorials on the web you should probably read.....
KriS
Posts: 6
Joined: Fri Nov 13, 2009 8:12 pm
Contact:

Post by KriS »

jbit wrote:This probably means it wants you to use: XOpenDisplay(NULL);... not passing NULL as a string....
Yes, I'm using XOpenDisplay( NULL ). I also tried ":0.0" (the value of my DISPLAY env variable).
jbit wrote:There are plenty of xlib tutorials on the web you should probably read.....
I was googling for a 2 days, but couldn't find why XOpenDisplay doesn't work when linking with 64 bit X11 libs.
cheriff
Regular
Posts: 258
Joined: Wed Jun 23, 2004 5:35 pm
Location: Sydney.au

Post by cheriff »

is there an 'errno' or similar in xlib you could check for clues on why the call failed?

Maybe an strace would be helpful - sometimes missing file opens or something can be an indicator as to why things failed?

You do have the 64bin xlib library installed right? Although i'd expect some other failure mode if this is the case, but one never knows ...
Damn, I need a decent signature!
KriS
Posts: 6
Joined: Fri Nov 13, 2009 8:12 pm
Contact:

Post by KriS »

cheriff wrote: Maybe an strace would be helpful - sometimes missing file opens or something can be an indicator as to why things failed?
Thanks for the strace hint. This looks like a really useful tool.

Code: Select all

// 32 bit lib + XOpenDisplay( NULL )
socket(PF_FILE, SOCK_STREAM, 0) = 3
connect(3, {sa_family=AF_FILE, path="/tmp/.X11-unix/X0"...}, 19) = 0

// 32 bit lib + XOpenDisplay( 'localhost.localdomain:0.0" )
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(6000), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)

// 64 bit lib + XOpenDisplay with any param
socket(PF_UNSPEC, 0 /* SOCK_??? */, 0)  = 3
connect(0, NULL, 0)                     = -1 ECONNREFUSED (Connection refused)
Calls for the 64bit version look very strange too me. For example manuals don't mention that you can pass NULL as addr to connect.

Also it looks like that I may have some problems with network. I tried to disable firewall, but I can't force 32 bit version to connect to "localhost.localdomain".
cheriff wrote: You do have the 64bin xlib library installed right? Although i'd expect some other failure mode if this is the case, but one never knows ...
I have reinstalled x11-devel rpms with dependencies and there are some files like libX11.so in lib64 folder. If I remove them I get missing lib errors, so I think I have this lib installed :).
Post Reply