Qt 应用程序编译失败

标签 qt ubuntu compilation qt5

我刚刚安装了 Qt5 并配备了“使用 QT 4 进行 C++ GUI 编程(第 2 版)”,我试图编译一个非常应用程序的代码,如下所示:
-test.pro:

SOURCES += \
  main.cpp
QT+=widgets

和 main.cpp :
#include <QApplication>
#include  <QLabel>

int main(int argc,char *argv[]){
    QApplication app(argc,argv);
    QLabel * label = new QLabel("hello world");
    label->show();
   return app.exec();
}

以下是错误:
19:45:21: Running steps for project test...
19:45:21: Configuration unchanged, skipping qmake step.
19:45:21: Starting: "/usr/bin/make" 
g++ -Wl,-rpath,/opt/Qt5.2.0/5.2.0/gcc -Wl,-rpath,/opt/Qt5.2.0/5.2.0/gcc/lib -o test main.o   -L/opt/Qt5.2.0/5.2.0/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread 
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [test] Error 1
19:45:21: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project test (kit: Desktop Qt 5.2.0 GCC 32bit)
When executing step 'Make'
19:45:21: Elapsed time: 00:00.

我正在使用 ubuntu 13.10 x86。

最佳答案

在您的机器上安装 OpenGL。它丢失了,您的 make 文件需要它来构建项目(“-lGL 缺失”)。

关于Qt 应用程序编译失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21560844/

相关文章:

linux - OpenCL 设备仅对 root 可见

c++ - 使用 Cygwin 编译 C++ 项目

performance - QGraphicsScene/QGraphicsView 性能

c++ - 与应用程序的链接错误

bash - 如何在 Google Cloud Build 步骤中使用之前从 bash 脚本文件中删除所有 CR (\r) 字符?

sql - 使用 bash 命令在 postgresql 中创建数据库

python - 编译 io 编程语言时出错

c - 使用 makefile 编译时,如何在不使用命令 'make clean' 的情况下清理目标文件?

c++ - Linux/CUPS Qt打印实例

c++ - Qt 的 Sunbird 中的时间表/日期簿?