简体   繁体   English

在cygwin上运行gui应用程序

[英]Run a gui application on cygwin

I am building application that is using OpenCV lib to show images. 我正在构建使用OpenCV lib来显示图像的应用程序。 The application fails at the following line: 应用程序在以下行失败:

cv::namedWindow(....);

I am using cygwin on Windows 10, and using CLion IDE. 我在Windows 10上使用cygwin,并使用CLion IDE。

The executable is built successfully but when run it shows the following error: 可执行文件已成功构建,但运行时显示以下错误:

(Display Image:10340): Gtk-WARNING **: cannot open display:

I made sure xinit is installed and its dependencies using cygwin setup. 我确保使用cygwin安装程序安装xinit及其依赖项。 I've run the x server using a batch file with the following content: 我使用包含以下内容的批处理文件运行x服务器:

c:\cygwin\bin\run.exe -p /usr/X11R6/bin XWin -listen tcp -multiwindow -clipboard -silent-dup-error

And I can see the 'X' icon in notification icons area, but still getting the error when I try to run the executable. 我可以在通知图标区域看到“X”图标,但在我尝试运行可执行文件时仍然出现错误。 I tried running it both from CLion and from cygwin console but same result. 我尝试从CLion和cygwin控制台运行它,但结果相同。

What is it that I am missing? 我错过了什么?

To run a program that need access to a X Server you need: 要运行需要访问X Server的程序,您需要:

1) a running X Server 1)正在运行的X Server
2) the variable DISPLAY defined 2)定义变量DISPLAY

If you check from Xterm you will have: 如果您从Xterm查询,您将拥有:

$ echo $DISPLAY
:0.0

So your program can run as DISPLAY is defined and the X server is found. 因此,您的程序可以在定义DISPLAY并找到X服务器的情况下运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM