Linux Qt can not find -lGL error perfect solution (effective pro-test)

http://c.biancheng.net/view/3901.html

 

For many Linux distributions, Qt installation is complete if the project directly compile or run, there will be "can not find -lGL" error, as shown below:

cannot find -lGL


This is because the Qt OpenGL can not find the dynamic-link library (libGL.so). In " Linux Qt install " section we said, OpenGL in most Linux distributions in is installed by default, including Ubuntu, CentOS, etc., can not find the link libraries are generally wrong path.

Find a dynamic link library Qt default in / usr / lib / directory, but many Linux distributions will link OpenGL library in another location, for example, I am using CentOS 7, OpenGL libraries located in / usr / lib64 / directory, and for Ubuntu, OpenGL libraries located in / usr / lib / i386-linux -gnu / mesa / directory. As long as we libGL.so copied to / usr / lib / directory, or create a link to libGL.so under / usr / lib / directory, will solve the problem. The second approach is clearly better.

In addition, Linux distributions comes with the OpenGL libraries added to the suffix in the version number, for example libGL.so.1, libGL.so.1.2.0, libGL.so.1.3.1, etc., but Qt look at the link stage OpenGL-link library is not versioned.

Collectively, we need to create a link to OpenGL libraries in / usr / lib / directory, and remove the version number.

If you do not know the exact path of the current Linux system libGL.so, you can use locate libGLthe command or find /usr -name libGL*commands to find and use ln -sto create the link. Consider the following presentations:

# Find libGL location
[root @ localhost ~] # the locate libGL
/usr/lib64/libGL.so
/usr/lib64/libGL.so.1
/usr/lib64/libGL.so.1.2.0
/ usr / report this content share / DOC /mesa-libGL-9.2.5
/usr/share/doc/mesa-libGL-9.2.5/COPYING

# create a link
[root @ localhost ~] # ln -s /usr/lib64/libGL.so.1 / usr / lib / libGL.so

There may be multiple versions of libGL.so Linux system, you can create a link to any version. Ordinary users do not have permission to create a link, so I used the root user.

Done, start Qt again, and then compile or run, it will not appear "can not find -lGL" mistake.

Guess you like

Origin www.cnblogs.com/xiang--liu/p/11641841.html