Important: Please read the Qt Code of Conduct -

[Solved] build error QT 5.02 gui application

  • I am new in QT.
    I have created Notepad example project.
    When I build it I have got an error:

    16:51:12: Starting: "/usr/bin/make"
    /home/sergey/Qt5.0.2/5.0.2/gcc_64/bin/qmake -spec linux-g++-64 CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ../Notepad/
    g++ -m64 -Wl,-rpath,/home/sergey/Qt5.0.2/5.0.2/gcc_64 -Wl,-rpath,/home/sergey/Qt5.0.2/5.0.2/gcc_64/lib -o Notepad main.o notepad.o moc_notepad.o -L/usr/X11R6/lib64 -L/usr/lib/x86_64-linux-gnu/mesa/ -L/home/sergey/Qt5.0.2/5.0.2/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
    /usr/bin/ld: cannot find -lGL
    collect2: ld returned 1 exit status
    make: *** [Notepad] Error 1
    16:51:12: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project Notepad (kit: Desktop Qt 5.0.2 GCC 64bit)
    When executing step 'Make'

    How to fix this error?

  • Hi,
    It seems you are missing the library on your system. You could either install OpenGL related stuff, or not use OpenGL at all (do you need it for your apps? this is not necessary to start learning and for Notepad apps).

  • I have in /usr/lib/x86_64-linux-gnu/mesa. It is symbolic link to in the same folder. There is also in the same folder. But it seams that qt don't see them.
    I try to

    1. add INCLUDEPATH += /usr/lib/x86_64-linux-gnu/mesa
    2. add LIBS += -L/usr/lib/x86_64-linux-gnu/mesa/
      to .pro file of my app. One item at a time.
      That does not fix the problem. I have the same error.

    How can I exclude directive -lGL from qmake command or add the path to /usr/lib/x86_64-linux-gnu/mesa/

  • Lifetime Qt Champion


    The correct way to add a library path is:
    @LIBS += -L/usr/lib/x86_64-linux-gnu/mesa/@

    By the way, what system are you on ? That seems an unusual folder for mesa to installed

  • Hi SGaist,
    your recomendation does not help.
    I have got the same error.

  • I have ubuntu 12.05 64-bit on Virtual box on Windows 7
    I have QT 5.02 and Boot to QT(evaluation) for QT5 installed.

  • Lifetime Qt Champion

    How did you instal mesa ?

  • Hi SGaist,

    I install it during Boot to Qt intsaltion.
    1.Installing 32-bit support libraries
    sudo apt-get install g++-multilib ia32-libs

    There were no dependent libraries for isa32-libs. So first install libraries from which isa32-lib is dependent. During this installation I install mesa I think.

  • Projects in Boot to Qt Creator are building without errors. But there are no examples in Boot to Qt. So I install Qt 5.02 to get the examples.

  • I have solved the problem.

    I delete "-lGL" in file
    Before fix:
    after fix:

    In my example program I don' use opengl

  • The file name is:

  • The previous decision was only a patch.

    The real fix is to install packages:

    for ubuntu 12.04

    I was shure that I have installed those packages, but it was not so.

  • File /home/sergey/Qt5.0.2/5.0.2/gcc_64/mkspecs/common/linux.conf
    must be restored to it's original state

  • It has been almost a year an your suggestion about installing:
    After installation my issue of: "error: cannot find -lGL" resolved
    Thanks esers!

Log in to reply