Some problems with compiling Qt dynamic link library under Linux system: "ln: Cannot create symbolic chain'lib*.so': operation not supported, "cannot find -lGL"

The problem of Qt compiling dynamic link library under linux system.

The original Qt project was written in Qt 5.11 on Windows. It includes two parts: main program ( .exe) project + dynamic link library ( .dll) project.
The Ubuntu system was created in the VM, and Qt 5.9.0 version was installed (the name of the Qt 5.9.0 Linux installation package is qt-opensource-linux-x64-5.9.0.run). The
original idea is that the virtual machine and the host Create a shared folder between. Put the Qt project in the shared folder and compile it directly with Qt in the Linux system. After the compilation is complete. Go back to the win system and copy the compilation result directly.

Question 1: "ln: Unable to create symbolic link'lib*.so': Operation not supported"

When compiling the dll project under Linux, *.so, .so.1, .so.1.0 files cannot be generated , only *.so.1.0.0 is generated. The error reported is "ln: Unable to create symbolic link'lib*.so': Operation not supported".
The reason for this error is: Windows can only create hard links in the NTFS file system, and only files in the same file system can create hard links. The compiled dll project source code is placed in the shared directory of windows and linux virtual machine. The file system where the shared directory is located is not the same file system as the linux file system, so hard links cannot be created. Move the dll project source code to the folder of the linux system to solve the problem.

Question 2: "cannot find -lGL"

When compiling the main program project under Linux, the error "cannot find -lGL" and "collect2:ld returned 1 exit status" appear.
The reason for this error is: Qt cannot find the OpenGL dynamic link library (libGL.so). Usually caused by the wrong path.

By default, Qt looks for dynamic link libraries in the /usr/lib/ directory, but many Linux distributions put OpenGL link libraries in other directories. For example, I use ukylin. The OpenGL link library is located in /usr/lib/x86_64-linux-gnu/ table of Contents. Just copy libGL.so to the /usr/lib/ directory, or create a link for libGL.so in the /usr/lib/ directory to solve the problem.
In addition, the OpenGL link library that comes with the Linux distribution adds the version number to the suffix, such as libGL.so.1, libGL.so.1.7.0, libGL.so.1.3.1, etc., but Qt looks for it in the link phase The OpenGL link library does not have a version number.
In summary, we need to create a link for the OpenGL link library in the /usr/lib/ directory and remove the version number.
First use the find /usr -name libGL*command to find the directory where the OpenGL link library is located,

ukylin@ukylin-virtual-machine:~$ find /usr -name libGL*

Then use ln -screate link (root user).

ukylin@ukylin-virtual-machine:~$ sudo ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 /usr/lib/libGL.so

There may be multiple versions of libGL.so in the Linux system, just create a link for any one version.
After completing the above operations, start Qt again, and then compile or run, there will be no "cannot find -lGL" error.

Guess you like

Origin blog.csdn.net/SmartTiger_CSL/article/details/105311260