Qt5 compile problem on Debian Jessie

I’m trying to compile a simple qt5 qml application on Debian Jessie.

At first I got following error from qmake:

Project ERROR: Unknown module(s) in QT: quick qml

It is caused by some development package not installed by default. You need to install qtdeclarative5-dev package:

sudo apt-get install qtdeclarative5-dev

Now qmake works but when I run make, it couldn’t find OpenGL library:

g++ -m64 -Wl,-O1 -o example-gui main.o qrc_qml.o   -L/usr/X11R6/lib64 -lQt5Quick -lQt5Qml -lQt5Widgets -lQt5Network -lQt5Gui -lQt5Core -lGL -lpthread 
/usr/bin/ld: cannot find -lGL

After some Googling I see that libgl1-mesa-dev package required but it is already installed and I have a file on /usr/lib/x86_64-linux-gnu/libGL.so, I couldn’t understand why linkage still fail.

/usr/lib/x86_64-linux-gnu/libGL.so file just a link to libGL.so.1.2.0 under same directory.

When I search the package from that file, it shows that it is included in libgl1-mesa-glx package:

dpkg -S libGL.so.1.2.0
libgl1-mesa-glx:amd64: /usr/lib/x86_64-linux-gnu/libGL.so.1.2.0

So, I think you have a strange problem, maybe it is related with the Debian Jessie edition which is not released as stable. You can solve the problems with reinstalling libgl1-mesa-glx package:

sudo apt-get install --reinstall libgl1-mesa-glx