Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 无法在虚拟机上初始化GLX--CLI_Qt_Opengl_Virtual Machine - Fatal编程技术网

Qt 无法在虚拟机上初始化GLX--CLI

Qt 无法在虚拟机上初始化GLX--CLI,qt,opengl,virtual-machine,Qt,Opengl,Virtual Machine,我创建了一个带有GUI的Qt应用程序,该GUI也可以在命令行上运行(从不调用QMainWindow::show()。当我试图在Debian虚拟机上运行时,我会得到错误: $ xvfb-run ./myApp Could not initialize GLX Aborted 我在Ubuntu16.04上构建了它,动态链接到Qt库,并复制了所需的库。它以前工作,但在我更新应用程序后开始出现此错误。如何确定此错误是由于缺少依赖项还是由于xvfb的某些问题造成的?问题很可能是因为您实例化了QAppl

我创建了一个带有GUI的Qt应用程序,该GUI也可以在命令行上运行(从不调用QMainWindow::show()。当我试图在Debian虚拟机上运行时,我会得到错误:

$ xvfb-run ./myApp
Could not initialize GLX 
Aborted

我在Ubuntu16.04上构建了它,动态链接到Qt库,并复制了所需的库。它以前工作,但在我更新应用程序后开始出现此错误。如何确定此错误是由于缺少依赖项还是由于xvfb的某些问题造成的?

问题很可能是因为您实例化了
QApplication
QGuiApplication
:不显示窗口是不够的。从命令行运行时,还需要仅使用
QCoreApplication

#include <QtWidgets>
#include <memory>
#ifdef Q_OS_WIN
#include <io.h>
int isatty(int fd) { return _isatty(fd); }
#else
#include <unistd.h>
#endif

using MyWindow = QWidget;

bool onCommandLine() {
   return isatty(0);
}

int main(int argc, char **argv) {
   std::unique_ptr<QCoreApplication> app(
            onCommandLine() ? new QCoreApplication(argc, argv)
                            : new QApplication(argc, argv));

   /* common logic goes here, e.g. argument parsing, etc. */    

   if (!onCommandLine()) {
      MyWindow w;
      w.show();
      return app->exec();
   } else
      return 0;
}
#包括
#包括
#如果你赢了
#包括
int isatty(int fd){return_isatty(fd);}
#否则
#包括
#恩迪夫
使用MyWindow=QWidget;
bool onCommandLine(){
返回isatty(0);
}
int main(int argc,字符**argv){
std::唯一的ptr应用程序(
onCommandLine()?新的QCore应用程序(argc、argv)
:新的QApplication(argc、argv));
/*此处使用通用逻辑,例如参数解析等。*/
如果(!onCommandLine()){
我的窗口w;
w、 show();
返回app->exec();
}否则
返回0;
}

问题很可能是因为您实例化了
QApplication
QGuiApplication
:不显示窗口是不够的。从命令行运行时,还需要仅使用
QCoreApplication

#include <QtWidgets>
#include <memory>
#ifdef Q_OS_WIN
#include <io.h>
int isatty(int fd) { return _isatty(fd); }
#else
#include <unistd.h>
#endif

using MyWindow = QWidget;

bool onCommandLine() {
   return isatty(0);
}

int main(int argc, char **argv) {
   std::unique_ptr<QCoreApplication> app(
            onCommandLine() ? new QCoreApplication(argc, argv)
                            : new QApplication(argc, argv));

   /* common logic goes here, e.g. argument parsing, etc. */    

   if (!onCommandLine()) {
      MyWindow w;
      w.show();
      return app->exec();
   } else
      return 0;
}
#包括
#包括
#如果你赢了
#包括
int isatty(int fd){return_isatty(fd);}
#否则
#包括
#恩迪夫
使用MyWindow=QWidget;
bool onCommandLine(){
返回isatty(0);
}
int main(int argc,字符**argv){
std::唯一的ptr应用程序(
onCommandLine()?新的QCore应用程序(argc、argv)
:新QApplication(argc,argv));
/*此处使用通用逻辑,例如参数解析等。*/
如果(!onCommandLine()){
我的窗口w;
w、 show();
返回app->exec();
}否则
返回0;
}
Xvfb不支持GLX/OpenGL。这就是全部。要么使用带有GPU驱动程序的完整Xorg服务器,要么使用无头EGL上下文

Xvfb不支持GLX/OpenGL。这就是全部。要么使用带有GPU驱动程序的完整Xorg服务器,要么使用无头EGL上下文