This post has been translated from German. For the original, please see the revision history.
I have written the following program in Qt Creator.
The error message refers to Ubuntu. I'm using Ubuntu 18.04 on a device with Intel i5.
I've been researching for days and have not found a solution yet.
What could be the problem and how can I fix it?
#include <QApplication>
#include <QPushButton>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPushButton button("Hallo Welt und so weiter");
button.move(250,300);
button.show();
return app.exec();
}
:-1: Fehler: collect2: error: ld returned 1 exit status
g++ -Wl,-rpath,/opt/Qt/5.11.1/gcc_64/lib -o HalloWelt main.o -L/opt/Qt/5.11.1/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
/usr/bin/x86_64-linux-gnu-ld: cannot find -lGL
Makefile:254: recipe for target 'HalloWelt' failed
collect2: error: ld returned 1 exit status
make: *** [HalloWelt] Error 1
16:12:14: Der Prozess "/usr/bin/make" wurde mit dem Rückgabewert 2 beendet.
Fehler beim Erstellen/Deployment des Projekts HalloWelt (Kit: Desktop Qt 5.11.1 GCC 64bit)
Bei der Ausführung von Schritt "Make"
16:12:14: Verstrichene Zeit: 00:00.
At first it is very strange that you have Qt in
/opt
.The correct way would be to install Qt 5.9.5 and other development packages from repository:
Then compile your program with
And run with
If you want to fix only
-lGL
error you should install one package: