/usr/bin/x86_64-linux-gnu-ld: cannot find -lGL












0















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.









share|improve this question





























    0















    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.









    share|improve this question



























      0












      0








      0








      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.









      share|improve this question
















      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.






      18.04 compiling gcc qt






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 10 '18 at 17:42









      Zanna

      50.4k13133241




      50.4k13133241










      asked Jul 10 '18 at 13:24









      GeorgiosGeorgios

      612




      612






















          1 Answer
          1






          active

          oldest

          votes


















          1














          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:



          sudo apt-get install qt5-default build-essential checkinstall 
          libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev
          libavcodec-dev libavutil-dev pkg-config


          Then compile your program with



          g++ HalloWelt.cpp $(pkg-config --cflags Qt5Widgets) $(pkg-config --libs Qt5Widgets) -fPIC -o HalloWelt


          And run with



          ./HalloWelt


          HalloWelt



          If you want to fix only -lGL error you should install one package:



          sudo apt-get install libgl1-mesa-dev





          share|improve this answer


























          • apt-get install build-essential checkinstall libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev libavcodec-dev libavutil-dev pkg-config

            – Georgios
            Jul 11 '18 at 7:56











          • @FahadNaeem please remove your comment from here and ask new question.

            – N0rbert
            Dec 27 '18 at 15:36











          • I ended up having unmet dependencies when I installed these packages. This solution does not work.

            – Fahad Naeem
            Dec 28 '18 at 4:30










          protected by N0rbert Dec 29 '18 at 7:19



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?














          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          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:



          sudo apt-get install qt5-default build-essential checkinstall 
          libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev
          libavcodec-dev libavutil-dev pkg-config


          Then compile your program with



          g++ HalloWelt.cpp $(pkg-config --cflags Qt5Widgets) $(pkg-config --libs Qt5Widgets) -fPIC -o HalloWelt


          And run with



          ./HalloWelt


          HalloWelt



          If you want to fix only -lGL error you should install one package:



          sudo apt-get install libgl1-mesa-dev





          share|improve this answer


























          • apt-get install build-essential checkinstall libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev libavcodec-dev libavutil-dev pkg-config

            – Georgios
            Jul 11 '18 at 7:56











          • @FahadNaeem please remove your comment from here and ask new question.

            – N0rbert
            Dec 27 '18 at 15:36











          • I ended up having unmet dependencies when I installed these packages. This solution does not work.

            – Fahad Naeem
            Dec 28 '18 at 4:30
















          1














          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:



          sudo apt-get install qt5-default build-essential checkinstall 
          libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev
          libavcodec-dev libavutil-dev pkg-config


          Then compile your program with



          g++ HalloWelt.cpp $(pkg-config --cflags Qt5Widgets) $(pkg-config --libs Qt5Widgets) -fPIC -o HalloWelt


          And run with



          ./HalloWelt


          HalloWelt



          If you want to fix only -lGL error you should install one package:



          sudo apt-get install libgl1-mesa-dev





          share|improve this answer


























          • apt-get install build-essential checkinstall libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev libavcodec-dev libavutil-dev pkg-config

            – Georgios
            Jul 11 '18 at 7:56











          • @FahadNaeem please remove your comment from here and ask new question.

            – N0rbert
            Dec 27 '18 at 15:36











          • I ended up having unmet dependencies when I installed these packages. This solution does not work.

            – Fahad Naeem
            Dec 28 '18 at 4:30














          1












          1








          1







          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:



          sudo apt-get install qt5-default build-essential checkinstall 
          libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev
          libavcodec-dev libavutil-dev pkg-config


          Then compile your program with



          g++ HalloWelt.cpp $(pkg-config --cflags Qt5Widgets) $(pkg-config --libs Qt5Widgets) -fPIC -o HalloWelt


          And run with



          ./HalloWelt


          HalloWelt



          If you want to fix only -lGL error you should install one package:



          sudo apt-get install libgl1-mesa-dev





          share|improve this answer















          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:



          sudo apt-get install qt5-default build-essential checkinstall 
          libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev
          libavcodec-dev libavutil-dev pkg-config


          Then compile your program with



          g++ HalloWelt.cpp $(pkg-config --cflags Qt5Widgets) $(pkg-config --libs Qt5Widgets) -fPIC -o HalloWelt


          And run with



          ./HalloWelt


          HalloWelt



          If you want to fix only -lGL error you should install one package:



          sudo apt-get install libgl1-mesa-dev






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 29 '18 at 7:26

























          answered Jul 10 '18 at 21:37









          N0rbertN0rbert

          21.7k547101




          21.7k547101













          • apt-get install build-essential checkinstall libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev libavcodec-dev libavutil-dev pkg-config

            – Georgios
            Jul 11 '18 at 7:56











          • @FahadNaeem please remove your comment from here and ask new question.

            – N0rbert
            Dec 27 '18 at 15:36











          • I ended up having unmet dependencies when I installed these packages. This solution does not work.

            – Fahad Naeem
            Dec 28 '18 at 4:30



















          • apt-get install build-essential checkinstall libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev libavcodec-dev libavutil-dev pkg-config

            – Georgios
            Jul 11 '18 at 7:56











          • @FahadNaeem please remove your comment from here and ask new question.

            – N0rbert
            Dec 27 '18 at 15:36











          • I ended up having unmet dependencies when I installed these packages. This solution does not work.

            – Fahad Naeem
            Dec 28 '18 at 4:30

















          apt-get install build-essential checkinstall libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev libavcodec-dev libavutil-dev pkg-config

          – Georgios
          Jul 11 '18 at 7:56





          apt-get install build-essential checkinstall libc6-dev libssl-dev libexpat1-dev libgl1-mesa-dev libqt4-dev libavcodec-dev libavutil-dev pkg-config

          – Georgios
          Jul 11 '18 at 7:56













          @FahadNaeem please remove your comment from here and ask new question.

          – N0rbert
          Dec 27 '18 at 15:36





          @FahadNaeem please remove your comment from here and ask new question.

          – N0rbert
          Dec 27 '18 at 15:36













          I ended up having unmet dependencies when I installed these packages. This solution does not work.

          – Fahad Naeem
          Dec 28 '18 at 4:30





          I ended up having unmet dependencies when I installed these packages. This solution does not work.

          – Fahad Naeem
          Dec 28 '18 at 4:30





          protected by N0rbert Dec 29 '18 at 7:19



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?



          Popular posts from this blog

          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

          Mangá

          Eduardo VII do Reino Unido