🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.linux.x
Article #229

Problem with C++ and X11R6

#229
From: Colm Buckley
Date: Tue, 26 Sep 1995 00:00
60 lines
2676 bytes
Any help on this problem would be appreciated :

I'm having difficulties using GNU C++ with X11R6 under Linux.  My setup
is as follows : a Pentium PC running Linux (1.3.29), XFree86 (3.1.2) and
GNU GCC (2.7.0).  Everything is built to use ELF shared libraries.

The following short program works perfectly when compiled under GCC as
a C program, but when I use G++ to compile it as a C++ program (I use
C++ with X11 a lot, so this is necessary, it gives a seg. violation
somewhere in the XOpenDisplay and coredumps.

#include <stdio.h>
#include <X11/Xlib.h>
}

int main()
{
        printf("Calling XOpenDisplay\n");
        fflush(stdout);
        if (XOpenDisplay(NULL) == NULL) {
                printf("XOpenDisplay failed\n");
        } else {
                printf("XOpenDisplay succeeded\n");
        }
        return 0;
}

Interestingly, this only happens when DISPLAY is set to certain
addresses - as the following sample runs demonstrate.  It *looks* like
it works when it uses Unix-domain connections and fails when it uses
TCP/IP-domain connections...

$ g++ -o test test.cc -L/usr/X11R6/lib -lX11
$ DISPLAY=picasso.cs.tcd.ie:0.0 ./test
Calling XOpenDisplay
zsh: 1160 segmentation fault  DISPLAY=picasso.cs.tcd.ie:0.0 ./test
$ DISPLAY=:0.0 ./test
Calling XOpenDisplay
XOpenDisplay succeeded
$ DISPLAY=unix:0.0 ./test
Calling XOpenDisplay
XOpenDisplay succeeded
$ DISPLAY=picasso:0.0 ./test
Calling XOpenDisplay
zsh: 1163 segmentation fault  DISPLAY=picasso:0.0 ./test
$ DISPLAY=picasso/unix:0.0 ./test
Calling XOpenDisplay
XOpenDisplay succeeded

Any ideas?  This is really bugging me and I have no idea what is causing
it...  before I go re-compiling the X libraries with debugging on; I'd
like to see if anyone else has encountered this problem.

                 Colm.

--
Colm Buckley          | EMail: Colm.Buckley@tcd.ie  Phone: (+353 1) 6082336
Computer Science Dept | WWW: http://isg.cs.tcd.ie/cbuckley/
Trinity College       | finger cbuckley@isg.cs.tcd.ie for more info.
Dublin 2, Ireland     | "Too many windows, not enough brain."
Technical Details
Message-ID: <448ok2$74r@news.cs.tcd.ie>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6cac,b3a7a03f48bfc602,start
X-Google-Attributes: gidf6cac,public
X-Google-Thread: f4bda,b3a7a03f48bfc602,start
X-Google-Attributes: gidf4bda,public
X-Google-Thread: 10ba33,b3a7a03f48bfc602,start
X-Google-Attributes: gid10ba33,public
From: cbuckley@cs.tcd.ie (Colm Buckley)
Subject: Problem with C++ and X11R6
Date: 1995/09/26
Message-ID: <448ok2$74r@news.cs.tcd.ie>
X-Deja-AN: 110796939
organization: TCD, Computer Science
newsgroups: comp.os.linux.x,gnu.g++.help,comp.windows.x.i386unix