Domanda

I am getting an issue as below when running a basic QtWidgets Application without any modification.

:-1: error: cannot find -lGL

I am using QtCreator version 3.0.0 Based on Qt 5.2.0 (GCC 4.6.1, 32 bit).

Note: QtConsole applications run without any problem

Project file looks like below

-------------------------------------------------

#

Project created by QtCreator 2014-01-04T13:38:17

#

-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = second TEMPLATE = app

SOURCES += main.cpp\ mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

main.cpp

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

}

MainWindow::~MainWindow()
{
    delete ui;
}
È stato utile?

Soluzione

This means, you do not either have an OpenGL library installed properly on your system, or the library path is wrong.

You will need to install the following package as per documentation on your Ubuntu box:

sudo apt-get intall libglu1-mesa-dev 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top