Unable to Open an X11 display on MacOSX
I've developed an Xlib program which runs with no problems in my Linux Mandrake 9.2. I sent a copy of the source to a friend who uses OSX Panther with X11 for Mac. He could compile it with no errors but a 'Bus error' message appeared. By doing some kind of 'e-debugging' I found I was getting a null display with
Code:
display = XOpenDisplay(NULL); Anybody knows why may this be happening or had a similar problem? I'm not sure if he was using OSX's UNIX terminal or X terminal, does this matter? |
He has to lauch apple X11 app first, then type in a xterm provided by apple X11
|
Quote:
Make sure that the X11 server is running (so click on it in /Applications/Utilities/X11 for Apples X11 implementation or wherever it is installed) and if he is running from the Terminal, make sure he types 'export DISPLAY=0:0' (for the now default bash shell) before trying to run it. Alternatively run straight from an xterm which probably opens automatically when starting X11. I'm not a Mac or X11 expert, but following these steps I haven't had any problems thus far. Error messages do vary a bit though, but I would have expected a message like "could not open display". |
Thanks, we solved everything by running the app in xterm. About dakensta's post, is it possible to run an X11 server by some kind of
Code:
system("command"); I don't want Mac users being forced to use any kind of term. |
you could use :
system("open /Applications/Utilities/X11.app"); to make sure X11 is started first, but assuming the user did not move the X11.app in another location. |
When everything seems is going to work well, and you have done 99% of normal work, you find that the last 1% is such a weird bug that doesn't look like having a solution. This is my case. Let me continue my story a bit:
"Yes, it works with Xterm. I've attached a screenshot of your program to the e-mail." "OK, thanks. But the version you compiled is deprecated! I'm sending you the new beta before it's publicly released. Compile it so I can make a binary release for both Linux and Mac." The new version I'm refering only fixes a couple of bugs and adds small functionality. "It doesn't work now!" Now comes a long, long debugging session which finishes with the following code: Code:
fastBMP = XShmCreateImage(hDC.display, DefaultVisual(hDC.display, hDC.nScreen), And here is the output he sent me: Code:
Default display is ':0.0' "I'm gonna kill you! Error 12 (ENOMEM) stands for not enough memory available!" "But I do have free memory! Take a look at this:" Code:
Processes: 62 total, 6 running, 56 sleeping... 186 threads 00:58:32 |
All times are GMT -5. The time now is 04:19 AM. |