在 Raspbian Stretch Lite 上,2018年11月, 使用以下 Qt5 GUI应用程序:
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel label("Hello world !");
label.show();
return app.exec();
}
以及以下项目文件:
######################################################################
# Automatically generated by qmake (3.0) Tue Mar 5 01:53:35 2019
######################################################################
TEMPLATE = app
QT += widgets
TARGET = hello
INCLUDEPATH += .
# Input
SOURCES += hello.cpp
我做了如下:
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -isystem /usr/include/arm-linux-gnueabihf/qt5 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWidgets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtGui -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore -I. -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -o hello.o hello.cpp
g++ -Wl,-O1 -o hello hello.o -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread
然后执行它,我得到以下错误消息:
./hello
QXcbConnection: Could not connect to display
Aborted
有人知道如何配置在没有X的EGL或FB目录上运行的Qt Gui应用程序吗?谢谢您的帮助!