32

I am running Windows 10 on my Surface Pro 3. I installed Cygwin and also added some useful packages (gvim, nedit, emacs, vim, g++). However, when I run gvim, I get "Can't open display". The same thing happens with nedit. When I did echo $DISPLAY, I showed nothing so I set the DISPLAY to :0.0. I still get "can't open display." I tried removing cygwin and re-installing but I get the same problem.

2
  • 1
    Sounds like the X11 server isn't running. Have you worked through the steps at x.cygwin.com ?
    – thrig
    Commented Sep 6, 2015 at 17:11
  • Let me also clarify that I am running Cygwin on my machine, where I am an admin. Yes, I did install the x11 packages, and looked through the x11 issues but that doesn't solve the problem.
    – John
    Commented Sep 6, 2015 at 17:17

7 Answers 7

30

Unix GUI programs display through an X server. Cygwin doesn't automatically start an X server. You need to install the packages xorg-server and xinit, and run startxwin.

1
13

Source : CygwinX FAQ :

Since X server 1.17, by default the server does not listen for TCP/IP connections, only accepting local connections on a unix domain socket. For local clients, use DISPLAY=:0.0, rather than DISPLAY=localhost:0.0, DISPLAY=127.0.0.1:0.0, DISPLAY=::1:0.0, etc

If it does not work (if you are connecting from remote): Use the -listen tcp option to restore the previous behaviour, allowing the X server to open a TCP/IP socket as well e.g.

startxwin -- -listen tcp

Finally, don't forget to run xhost + in the Cygwin terminal.

6

What helped me is changing

DISPLAY=:0.0 <mycommand>

to

DISPLAY=localhost:0.0 <mycommand>
1
  • odd, running locally, after installing all the packages and first running xlaunch with the default display (0), the following command works for me: DISPLAY=:0.0 gimp
    – theRiley
    Commented Mar 12, 2019 at 18:15
2

You can also use XLaunch/Xming.

  • Open XLaunch, choose "Multiple Windows", and set a Display number (doesn't matter).
  • In Cygwin, export DISPLAY=[whatever your XLaunch Display number is].
  • Launch your program with gvim &
1

How I got it working:

  • Install packages xorg-server and xinit.
  • Run this commands in a Cygwin shell window:

    startxwin

    DISPLAY=localhost:0.0 xterm

However, to be honest, the default CygWin console is nicer than XTerm, so I continued to use that.

0

I run graphic programs without a script, i.e. startxwin <myapp> the following way:

  1. For my command in /etc/bash.bashrc:
export DISPLAY=:0.0
  1. Start the XWin Server with the standard command:
C:\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; exec /usr/bin/startxwin"
  1. Start your graph application from terminal, for example:
/bin/kate

P.S. I solved my error with Eclipse IDE:

qt.qpa.screen: QXcbConnection: Could not connect to display <...>
Could not connect to any X display.

I added a Windows system variable: DISPLAY=:0.0

-1

just export it

export DISPLAY=localhost:0.0

to make persistant add that to your .bash_profile

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .