Hmm, that's odd. I definitely wrote "#include <assert.h>" both times,
with a space between "#include" and "<", but the quoted material in your
followup shows it as "#include<assert.h>" without the space. Did your
newsreader do that?
Anyway ...
> I got it to run under debian but i am having problems getting it to
> work on the console / terminal in freebsd. I have been trying to find
> out if a window manager is necessary to run this but am not able to
> find clear documentation on this point. I am trying to get this to
> work on a system that does have x windows configured - but I am not
> invoking it from within x windows.
Did you try adding the "#include <assert.h>" as I suggested? Did it
make a difference?
A window manager shouldn't be necessary, as long as you have a usable X
server running. But it would be quite unusual to be running an X server
with no window manager.
And if you don't, the assert() should fail unless you've defined NDEBUG.
But really, assert() should be used to catch programming errors, not
run-time errors. It's a way of saying "This should never happen, but if
it does, tell me about it and give up on doing anything else."
For XOpenDisplay(NULL) to work, you need to have the environment
variable $DISPLAY set to something valid, such as ":0.0". This *should*
be set for you automatically. Try running a simple known-to-work X11
program such as xlogo; this will tell you whether it's a problem with
the X server or a problem in your program.
First see if you can get the assert() to work without causing a
segmentation fault. Then I suggest replacing the assert() with
something like:
if (dpy == NULL) {
fprintf(stderr, "XOpenDisplay failed\n");
exit(EXIT_FAILURE);
}
And what *exactly* does "problems getting it to work" mean? Is this
still the segmentation fault problem?
If your problem is with X11, you might try posting in one of the
comp.windows.x newsgroups (assuming they're still active, I haven't
visited lately).